尝试以下..
bool success = File.Exists(@"\\comp01\BatchFiles\InputFile\Test.txt");
Run Code Online (Sandbox Code Playgroud)
它的返回false
(文件确实存在)
当我尝试
var dirInfo = new DirectoryInfo(@"\\comp01\BatchFiles\InputFile");
if (dirInfo.Exists)
Run Code Online (Sandbox Code Playgroud)
它回来了true
.
所以它可以找到路径而不是文件?
有什么理由吗?
创建一个FileInfo实例并检查它是否存在;
FileInfo fi = new FileInfo(@"\\comp01\BatchFiles\InputFile\Test.txt");
var exists = fi.Exists;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8623 次 |
最近记录: |