SaveFileDialog - how to stop the user from changing the FileName [C#]

Shaitan00

Junior Contributor
Joined
Aug 11, 2003
Messages
358
Location
Hell
In my application I am using a SaveFileDialog to prompt the user to save a generated file to a specific location - however I need to ensure that the file name itself cannot be changed...

For example, I have the following code:
Code:
saveFileDialog.Title = "Save File";
saveFileDialog.InitialDirectory = "C:\\";
saveFileDialog.Filter = "Zip File (*.zip)|*.zip";
saveFileDialog.FileName = "A.ZIP";
if (saveFileDialog.ShowDialog() != DialogResult.Cancel)
   File.Copy(sFile, saveFileDialog.FileName, true);

Now, this works perfectly fine, the default under file name is "A.ZIP" but the user can change that and save it as anything they want, I need to ensure they cannot change the file name (A.ZIP) and only define where the file should be saved ...

Is there a way to set that field as read-only (for example?)
Any help, hints, or ideas would be much appreciated.

Thanks,
 
See thats my problem - using the FolderBrowserDialog the user has no clue what file he is saving ... they need to know the file name (so they can go collect it later) but not be able to change it ..

Any clues?
 
See thats my problem - using the FolderBrowserDialog the user has no clue what file he is saving ... they need to know the file name (so they can go collect it later) but not be able to change it ..

Any clues?

Why not display the file's name via the description property of the FolderBrowserDialog? I.e.
Code:
folderBrowserDialog1.Description = "Select a folder to save A.zip";
Either that, or ignore the filename specified by the user.
 
Back
Top