Skip to content

Setup and select a full path based on a dialog box in C#

November 10, 2015

A useful method that my colleague wrote that allows you to setup and select a full path based on a dialog box in C# is shown below:-

public static string SaveFile()
{
string path = “”;
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = “csv files (*.csv)|*.csv|All files (*.*)|*.*”;
saveFileDialog1.RestoreDirectory = true;
saveFileDialog1.FileName = “test”;

if (saveFileDialog1.ShowDialog() == true)
{
path = (saveFileDialog1.FileName);
}
return path;
}

I found it very useful for utilising the existing WPF class FileDialog than using Telerik to custom build a file dialog box.

Advertisements

From → Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: