openfiledialog control locks folder

来源:互联网 发布:淘宝网禁止出售中药材 编辑:程序博客网 时间:2024/06/11 11:17

XP下在打开OpenFileDialog后,不能修改目录的名称,提示 "The action can't be completed because the folder is open in another program. Close the folder and try again."

解决方法:

var dlg = new OpenFileDialog;
          dlg.RestoreDirectory = true;
    if (dlg.ShowDialog(this) == DialogResult.OK)
{

try

            {
                Stream fileStream = dlg.OpenFile();
                fileStream.Close();
            }

            catch {}

}




原创粉丝点击