views:

300

answers:

2

In my application I use a SaveFileDialog to pop up a Save As window. I have restricted in the file type section the file to be saved as .dat with the following code.

sfdialog.Filter = "Data Files (*.dat*)|*.dat*";

What I want to know how to do is make it automatically save with the .dat extension. Currently it just saves with no extension unless I specifically save it as filename.dat.

+5  A: 
SaveFileDialog dlg = new SaveFileDialog();
dlg.DefaultExt = "dat";
dlg.AddExtension = true;
Francis B.
Perfect thank you. I'd up-vote but I don't have enough rep.
novacara
+1  A: 

The AddExtension and DefaultExt properties. For example:

sfdialog.DefaultExt = "dat";
sfdialog.AddExtension = True;
John Calsbeek