我正在尝试使用c#console应用程序从不同服务器读取文件,但它出错 - “指定的网络名称不再可用”。
当我ping服务器时,我收到了回复,但是当我运行具有代码的项目的exe文件来访问服务器中的文件时,它会显示上述错误。
我使用的路径采用以下格式:\\ xxx.xxx.xx.x \ EEE \ EEE \ FolderName
访问/读取文件的代码:
public List<string> GetFiles()
{
List<string> filelist = null;
string fileFromPath = help.fileFromPath;
try
{
filelist = Directory.GetFiles(fileFromPath).ToList();
if (filelist.Count == 0)
{
log.Error("No file to be processed.");
}
}
catch (Exception ex)
{
log.Error(ex.Message);
}
return filelist;
}
其中help.fileFromPath具有路径值,并存储在app.config
中请告知可能的原因以及如何解决?
提前致谢。