OpenFileDialog default path

前端 未结 8 1387
甜味超标
甜味超标 2020-12-01 14:13
using (var openFileDialog1 = new OpenFileDialog())
        {
            openFileDialog1.Reset();
            if (!string.IsNullOrEmpty(ExcelFilePath))
            {         


        
8条回答
  •  情深已故
    2020-12-01 14:46

    It seems like all you need to do is the following:

    string path; // this is the path that you are checking.
    if(Directory.Exists(path)) {
        openFileDialog1.InitialDirectory = path;
    } else {
        openFileDialog1.InitialDirectory = @"C:\";
    } 
    

    That is unless I'm missing something.

提交回复
热议问题