用于使用目录信息class-ASP.net查找远程机器中文件夹大小的代码

时间:2021-04-12 02:11:02

I need the code for finding the size of a folder in remote machine(server). I tried using directory info class , but its ending up in error"The UNC path should be of the form \server\share". I tried different combinations , but the error appears to be same. CODE IN SOURCE FILE IS AS FOLLOWS

我需要代码来查找远程机器(服务器)中文件夹的大小。我尝试使用目录信息类,但最终错误“UNC路径应该是\ server \ share”。我尝试了不同的组合,但错误似乎相同。源文件中的代码如下

strPath = ConfigurationManager.AppSettings["RetryFolderPath"].DirectoryInfo dInfo = new DirectoryInfo(strPath);
          long size = DirSize(dInfo, true);
          long totalSize = 0;
          foreach (FileInfo fi in dInfo.GetFiles())
           {
              totalSize += dInfo.Length;
              xlWorkSheet.get_Range("E" + iIndex, misValue).Cells.Value = Decimal.Round(size / mb, 2).ToString() + "mb";
           }

PATH GIVEN IN CONFIG FILE IS AS FOLLOWS

配置文件中的路径如下

<add key="RetryFolderPath" value="\\machineipor server name\folder_path"/>

1 个解决方案

#1


0  

guess your property is actually empty, due to the fact you are using ConfigurationManager while on ASP.NET. The right class for ASP.NET is WebConfigurationManager:

猜测你的属性实际上是空的,因为你在ASP.NET上使用ConfigurationManager。 ASP.NET的正确类是WebConfigurationManager:

strPath = WebConfigurationManager.AppSettings["RetryFolderPath"]

#1


0  

guess your property is actually empty, due to the fact you are using ConfigurationManager while on ASP.NET. The right class for ASP.NET is WebConfigurationManager:

猜测你的属性实际上是空的,因为你在ASP.NET上使用ConfigurationManager。 ASP.NET的正确类是WebConfigurationManager:

strPath = WebConfigurationManager.AppSettings["RetryFolderPath"]