Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return the full path of the SaveFileDialog?

Tags:

c#

wpf

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"

like image 579
KMC Avatar asked Jun 07 '11 04:06

KMC


People also ask

How to Save a file with SaveFileDialog?

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.

How to Save file using SaveFileDialog in vb net?

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.

How to Save file from openfiledialog in c#?

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.


2 Answers

"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.

like image 146
Nik Avatar answered Oct 16 '22 01:10

Nik


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?

like image 33
Xiodine Avatar answered Oct 16 '22 01:10

Xiodine