c# - How to save the specific textboxes with special order to a text file? -


i want use button save contents. here code! can't see show on text file. can me? way? how choose saving location whatever choose? it's seems save in debug folder.

private void button1_click_1(object sender, eventargs e) {     savefiledialog save = new savefiledialog();     save.filename = "parameters.txt";     save.filter = "text file | *.txt";     system.io.streamwriter file = new system.io.streamwriter(save.filename);     if (save.showdialog() == system.windows.forms.dialogresult.ok)     {          file.write("===========parameters===========" + "\r\n");         file.write("number of teeth: " + textbox1.text + "\r\n");            *           *           *           *         file.close();         messagebox.show("saving succeed(parameters)");     } } 

try this:

        savefiledialog save = new savefiledialog();      // save.filename = "parameters.txt";         save.filter = "text file | *.txt";        if (save.showdialog() == system.windows.forms.dialogresult.ok)        {            using (system.io.streamwriter file = new system.io.streamwriter(save.filename))            {                file.write("===========parameters===========" + "\r\n");                file.write("number of teeth: " + "\r\n");                 // file.close();                messagebox.show("saving succeed(parameters)");            }         } 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -