Reputation: 2333
In the following c# class displaying a Windows.Forms.OpenFileDialog
how could I store the data path into the variable called m_settings
?
private SomeKindOfData m_settings;
public void ShowSettingsGui()
{
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
ofd.Multiselect = true;
ofd.Filter = "Data Sources (*.ini)|*.ini*|All Files|*.*";
if (ofd.ShowDialog() == DialogResult.OK)
{
string[] filePath = ofd.FileNames;
string[] safeFilePath = ofd.SafeFileNames;
}
m_settings = //<-- ?
}
Upvotes: 1
Views: 1199
Reputation: 65087
This should do the trick:
m_settings = ofd.FileName;
EDIT: Actually, now I'm not sure if you wanted the folder path. In that case:
m_settings = Path.GetDirectoryName(ofd.FileName);
Upvotes: 2