C# 判断 映射网络驱动器的文件是否存在,用什么方法啊?
写了一个 windows 服务。里面要判断网络驱动器里的文件是否存在:代码如下
try
{
string path = @"Y:\1.txt";
if (File.Exists(path))
{
FileStream fs = new FileStream(path, FileMode.Open);
StreamReader reader = new StreamReader(fs);
string mes = reader.ReadToEnd();
log.Info"---" + mes);
reader.Close();
fs.Close();
}
else
{
log.Info(path + "不能够访问");
}
}
catch (Exception e)
{
log.Info(e + "出错了");
throw;
}
但是 文件明明存在就是 执行: path+"不能访问"。我也知道是权限的问题,但是不知道怎么解决,还望大家看看。