在下面显示Windows.Forms.OpenFileDialog的c#类中,如何将数据路径存储到名为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 = //<-- ?
}发布于 2012-07-24 08:08:32
这应该能起到作用:
m_settings = ofd.FileName;编辑:实际上,现在我不确定你是否想要文件夹路径。在这种情况下:
m_settings = Path.GetDirectoryName(ofd.FileName);https://stackoverflow.com/questions/11622330
复制相似问题