[英]code for finding the size of a folder in remote machine using directory info class- ASP.net
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".
我尝试使用目录信息类,但其结果以错误“ UNC路径应为\\ server \\ share形式”结尾。 I tried different combinations , but the error appears to be same.
我尝试了不同的组合,但错误似乎相同。 CODE IN SOURCE FILE IS AS FOLLOWS
源文件中的代码如下
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"/>
guess your property is actually empty, due to the fact you are using ConfigurationManager
while on ASP.NET. 由于您在ASP.NET上使用
ConfigurationManager
,因此猜测您的属性实际上为空。 The right class for ASP.NET is WebConfigurationManager
: ASP.NET的正确类是
WebConfigurationManager
:
strPath = WebConfigurationManager.AppSettings["RetryFolderPath"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.