Openfiledialog问题,文件描述错误

问题描述 投票:0回答:1

Iam使用VS2015-Windows窗体。当我单击浏览按钮时,OpenFileDialog正常运行。但是假设一旦我在刷新表单数据后重新单击按钮,OpenFileDialog就会挂断。

我无法理解我的问题。任何上司都可以指导我吗?

MyFileNameStr = String.Empty;
openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "D:\\";
openFileDialog1.Filter = "(*.xlsx)|*.xls| All files (*.*)|*.*";
openFileDialog1.RestoreDirectory = true;
openFileDialog1.Title = "Select Your Attachment File :- ";
openFileDialog1.FileName = "";
if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK && openFileDialog1.FileName.Length>0) {
    String MyDrawingFile = Path.GetFileName(openFileDialog1.FileName);
    myDataGrid1.CurrentRow.Cells["MyExcel_file"].Value = Path.GetFileName(openFileDialog1.FileName);
    MyFileNameStr = openFileDialog1.SafeFileName.ToString();
    MyFileNameStrs = openFileDialog1.SafeFileName.ToString().Split('_');
}

再次感谢

c# winforms visual-studio-2015 openfiledialog
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.