am so confused...wen you use save dialog....you only get the dialog and wen i say save, it saves....my problem is, wen you go back to the folder to check the file saved....nothin is there....i want to know how you can save a file to a certain folder and wen saved you can go back to that folder and find the file there........VERY URGENT

6 Years
Discussion Span
Last Post by JOSheaIV

The SaveFileDialog does not save anything. It is used to get the filename and path of where the user wants you to save the data.

You must test the return value from the ShowDialog method.
If it is DialogResult.OK you then save the data to a file using the FileName property from the SaveFileDialog.


SaveFileDialog only gets the path where the user wants to save, as nick.crane said.

You can then use that path to save the file. For instance, if you are using an image then you will have to use SomeImage.Save(SaveFileDialog.FileName) to save the image in the path specified by the user (using the SaveFileDialog).

Here's an example:

private void SaveBtn_Click(object sender, EventArgs e)
   DialogResult result = SaveFileDialog.ShowDialog();

   // Make sure the user has clicked "OK" or "Save"
   // and didn't cancel the dialog
   if(result == DialogResult.OK)
      // for image


Edited by mike_2000_17: Fixed formatting


Saving (or persisting) data can mean many things depending upon what you want to save and where you want to save it.
The data could be stored in a DB, saved as a text file or a binary file.
The simplest of these is to save to a text file. This is helpful if you are just starting out with persistance as you can examine the saved file with Notepad.

Look at the help for


depends on how you want to save the file. If you are saving to store data that you can access when you open the program after closing it use


I am using that alot right now on a program I am working on. I would be more then happy to help you with that if you need it (I am really good at using these as my one file I save to outputs multiple data for one thing so I needed a unique way to read it in)


i finally was able to save contents of a form to a database...sql server databases.Thanks for all your help.totally appreciate


Btw if it all worekd out for you good to hear (sorry going over old posts) but if you are still having trouble I have finally learned how to use an excel file as a DB (took me forever to understand and I am still learning it but I got the basics down), so i can definitly help with that

Edited by JOSheaIV: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.