OpenFileDialog default path

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


        
8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 14:37

    Check to see if the ExcelFilePath exists, you check to see if it's null or empty, however if before your block you check to see if the directory exists, and if it doesn't reset the value to an empty string you should be golden.

    (yes you'll need to apply your file name logic etc earlier) however once you've parsed all of that out, it's trivial to determine if the directory exits

    if (!Directory.Exists(excelPath))
    {
        ExcelFilePath = String.Empty;
    }
    

提交回复
热议问题