ofd1.RestoreDirectory
但是,在我设置的以下代码false
中,对话框每次都会打开初始目录。有什么我不知道的吗?
private void btnMeshFile_Click(object sender, EventArgs e)
{
OpenFileDialog ofd1 = new OpenFileDialog();
ofd1.Title = "Open";
ofd1.InitialDirectory = @"c:\";
ofd1.Filter = "All files (*.*)|*.*|All files (*.*)|*.*";
ofd1.FilterIndex = 2;
ofd1.RestoreDirectory = false;
if (ofd1.ShowDialog() == DialogResult.OK)
{
string fileName = Path.GetFileName(ofd1.FileName);
MeshDirectoryPath = Path.GetFullPath(ofd1.FileName).Replace(@"\", @"\\");
txtMeshFile.Text = fileName;
}
}