正在写一个.aspx网页,有一个功能是在文本框里面输入一个文件名后,网页会查找指定路径上是否存在这个文件,并将文件信息返回.
现在使用DirectoryInfo可以查找本地硬盘里面的文件,但我映射了一个网络盘(Z:),却不能访问,使用Directory.Exists("z:\123")总是返回false.
z:是可以读写的.各位有什么办法吗?我需要访问网络共享盘上的文件.private FileInfo FindLog(LogFileAttrib logfileinfo, string sppid)
{
if(!Directory.Exists(logfileinfo.strPath))
{
Label3.Text += WriteInfo(string.Format(@"Could not found directory:{0}", logfileinfo.strPath), "red");
Label3.Text += "<P>";
return null;
} string strname = string.Format(@"*{0}*{1}*.log",logfileinfo.station,sppid); DirectoryInfo di = new DirectoryInfo(logfileinfo.strPath);
FileInfo[] fi;
try
{
fi = di.GetFiles(strname, SearchOption.AllDirectories);
if (fi.Length == 0)
{
Label3.Text += WriteInfo(string.Format(@"Not found file:{0}",strname), "red");
Label3.Text += "<P>";
return null;
}
else
{
return fi[fi.Length - 1];
}
}
catch (System.Exception e)
{
Label3.Text += WriteInfo(string.Format(@"Error:{0}",e.Message), "red");
Label3.Text += "<P>";
return null;
}
}
现在使用DirectoryInfo可以查找本地硬盘里面的文件,但我映射了一个网络盘(Z:),却不能访问,使用Directory.Exists("z:\123")总是返回false.
z:是可以读写的.各位有什么办法吗?我需要访问网络共享盘上的文件.private FileInfo FindLog(LogFileAttrib logfileinfo, string sppid)
{
if(!Directory.Exists(logfileinfo.strPath))
{
Label3.Text += WriteInfo(string.Format(@"Could not found directory:{0}", logfileinfo.strPath), "red");
Label3.Text += "<P>";
return null;
} string strname = string.Format(@"*{0}*{1}*.log",logfileinfo.station,sppid); DirectoryInfo di = new DirectoryInfo(logfileinfo.strPath);
FileInfo[] fi;
try
{
fi = di.GetFiles(strname, SearchOption.AllDirectories);
if (fi.Length == 0)
{
Label3.Text += WriteInfo(string.Format(@"Not found file:{0}",strname), "red");
Label3.Text += "<P>";
return null;
}
else
{
return fi[fi.Length - 1];
}
}
catch (System.Exception e)
{
Label3.Text += WriteInfo(string.Format(@"Error:{0}",e.Message), "red");
Label3.Text += "<P>";
return null;
}
}
使用ftpwebrequest获取数据