我的应用程序托管在192.14.14.22服务器上,并尝试从192.14.253.25 D驱动器中的另一个目录获取文件名列表,这是我们获得访问被拒绝的问题,但我可以访问//192.14.253.25/d来自run命令的$。我知道这是一个经常出现的问题,但我的查询是知道如何访问文件,因为我能够从我的PC和运行中访问它,但不能从应用程序访问它。我的代码是我的代码。
[NonAction]
public List<FilesListDTO> GetList()
{
List<FilesListDTO> lstFiles = null;
try
{
lstFiles = new List<FilesListDTO>();
DirectoryInfo dir = new DirectoryInfo(@'//192.14.253.25/d$');
lstFiles = dir.GetFiles().OrderBy(x => x.FullName).Select(x => new FilesListDTO
{
Filename = x.FullName.Replace(CDMSServerPath, string.Empty),
DateModified = x.CreationTimeUtc
}).OrderByDescending(c => c.DateModified).ToList();
}
catch (Exception ex)
{
Util.WriteLog("GetList Error:" + ex.Message);
}
return lstFiles;
}
我在web配置中使用下面的键解决了这个问题
<identity impersonate="true" userName="vcvcplicationrobot" password="xxxxxx"/>