How to get the full path string from a SaveFileDialog? SaveFileDialog.FileName
only gives me the filename with extension. I have looked into SaveFileDialog
on MSDN, but I don't see any property does that.
I need to return "C:\Folder1\subFolder2\File004.sdf" not just "File004.sf"
To save a file using the SaveFileDialog component. Display the Save File dialog box and call a method to save the file selected by the user. Use the SaveFileDialog component's OpenFile method to save the file. This method gives you a Stream object you can write to.
The SaveFileDialog control prompts the user to select a location for saving a file and allows the user to specify the name of the file to save data. The SaveFileDialog control class inherits from the abstract class FileDialog.
To copy the file to your project directory, you can do: string source = openFileDialog1. FileName; string dest = @"C:\Users\admin\source\repos\Software of TE\Software of TE\Images\" + Path. GetFileName(source); File.
"Gets or sets a string containing the full path of the file selected in a file dialog." is what the MSDN article you linked says for FileName
property. Plus, FileName
has always given me the full file path.
What I basically do is more or less
SaveFileDialog x = new SaveFileDialog();
if (x.ShowDialog() == DialogResult.OK)
{
//Use here x.FileName
}
and it always returned the full path. Are you sure you don't see the absolute path?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With