2015-10-09 123 views
0
protected void btnAutomaticUpload_Click(object sender, EventArgs e) 
{ 
    DirectoryInfo dir = new DirectoryInfo(@"\\space-bar\UZ\UZ Dept\Management\Data\directory_exists_here\"); 
    bool atLeastOneSuccessfulUpload = false; 
    bool possibleFormatChange = false; 

    lblMessages.Text = string.Empty; 
    lblResults.Text = "<span style='font-size:large; font-weight:bold'><u>Results Log</u></span><br><br>"; 

    //If our destination directory does not exist, exit 
    if (!dir.Exists) 
    { 
     lblResults.Text += "<span style='color:Red'>Expected directory does not exist!</span><br>" + dir.FullName; 
     return; 
    } 

因此,我一直试图在带有映射网络驱动器的活服务器上运行此代码,但它总是似乎无法找到该文件夹​​。虽然当我在Debug或LocalHost模式下运行时,它似乎能够找到没有问题的目录。任何想法,即使UNC路径编码,为什么它不起作用?这与权限有关吗?DirectoryInfo.Exists找不到我映射的网络驱动器C#

我想构建一个自动文件上传解析器。

+0

在调试时,代码是否在服务器和本地上以同一用户身份运行?如果他们是不同的用户,这可能是一个权限问题。 – PatrickSteele

回答

1

如果您在IIS下运行,它几乎肯定无权访问网络资源。检查IIS中的应用程序池标识以确定您的应用程序正在运行的用户 - 它可能是一个非常有限的系统帐户。这可以通过更改IIS管理器中的应用程序池设置进行更改。

+0

这似乎是答案。糟糕,因为我还没有访问IIS管理器。 –

相关问题