Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In My WPF Application,

I am using savefiledialog when button1.click like below code.
C#
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "Document"; // Default file name
dlg.DefaultExt = ".text"; // Default file extension
dlg.Filter = "Text documents (.txt)|*.txt"; // Filter files by extension 

Nullable<bool> result = dlg.ShowDialog();

if (result == true)
{
   string filename = dlg.FileName;
}

With out any error its Running, but its not saving to the system.
here i am using windows server 2008 r2 Enterprise edition 64bit operating system and vs2010.
can you please tell me any thing wrong here.
Posted
Updated 25-Feb-13 21:11pm
v4

1 solution

I see that your code is taken from MSDN page[^]. They forgot to mention, that YOU need to handle the save process by yourself, since there is no reference to Stream or byte array or something else you want to put into that file.
After checking the result, use something like this:
C#
File.WriteAllText(dialog.FileName, fileText)
 
Share this answer
 
Comments
D-Kishore 26-Feb-13 4:41am    
Thank you so much
Mine 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900