c# - Writing to text files using SaveFileDialog -


i'm working on add in microsoft excel in visual studio records balances each account (or worksheet) , saves them user-specified file. ability press button , select destination save work essential skill programmer, i'm perplexed why there little information on how it. closest thing found tutorial on msdn saves button icon image.

the code i'm using follows:

stringbuilder sb = new stringbuilder();  if (thisaddin.createdbudget) {     string budget = "budget = " + thisaddin.blake.budget;      savefiledialog savebudget = new savefiledialog();     savebudget.filter = "data files (*.dat)|*.dat|all files (*.*)|*.*";     savebudget.title = "save budget";     savebudget.showdialog();      if (savebudget.filename != "")     {         using (streamwriter sr = new streamwriter(savebudget.openfile()))         {             sb.appendline(budget);         }     } }  else {     messagebox.show("control disabled.  budget not yet exist."); } 

my objective allow user designate file path via savefiledialog , save new .dat (or .txt). stream writer record account names , respective balances line line. like:

sr.writeline(account1.name + " balance = " + account1.balance); sr.writeline(account2.name + " balance = " + account2.balance); etc... 

i know sounds complicated. have no problem saving data if i'm using predetermined file path, that's not helpful. need know how write files using savefiledialog.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -