【问题标题】:File.Exists not working on network, even if app is ran as administratorFile.Exists 无法在网络上运行,即使应用程序以管理员身份运行
【发布时间】:2017-01-29 06:12:18
【问题描述】:

我尝试在以管理员身份运行应用程序时检查网络上的文件是否存在,使用以下代码:

// file exists at : \\net0\shared\1.txt
var networkPath=@"\\net0\shared\1.txt";
var ex=File.Exists(networkPath);

ex 是假的。 我错过了什么吗?

【问题讨论】:

    标签: file networking .net-4.5 exists


    【解决方案1】:

    创建一个 FileInfo 实例并检查它是否存在:

    FileInfo fi = new FileInfo(@"\\net0\shared\1.txt");
    var exists = fi.Exists;
    

    【讨论】:

    • FileInfo 有同样的问题!
    • 您是否使用域管理员帐户来运行应用程序?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-29
    • 2017-05-19
    • 2011-09-24
    • 2010-12-19
    • 1970-01-01
    • 2014-12-27
    相关资源
    最近更新 更多