且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当我运行程序时,显示“系统找不到指定的路径".

更新时间:2023-10-19 13:17:58

在将路径传递到文件名之前添加以下行:

Add this line before passing path to file name:

using System.IO;



要检查路径是否存在:



To Check if path exists:

if(!Directory.Exists(path))
            {
//throw exception here or show message box like this:
MessageBox.Show(path);
            }
else
{
//do something here.
}



要检查文件是否存在:



To check if file exists:

if(File.Exists(filepath)
{
//throw exception here or show message box like this:
MessageBox.Show(filepath)
}
else
{
//do something here.
}


只需逐行调试,看看哪里出现此错误
Just debug line by line and see where you are getting this error