关于获得服务器端文件夹中文件信息的问题。

fanlly 2007-04-17 10:23:23
我现在用如下代码直接获得服务器端的文件:
WebRequest webRequest = WebRequest.Create("http://localhost/TestFolder/aa.xls");
WebResponse webResponse = null;
webResponse = webRequest.GetResponse();
但是现在需求变了,只要文件名为"a*.xls",就可能是我需要获得的文件,所以我得先获得服务器指定文件夹的所有文件的文件名称的列表,然后对比后确定我需要的文件的名称。问题是,我如何获得这个文件名列表?
另:用户希望使用不需要验证的Url,而非文件路径。
...全文
203 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hertcloud 2007-04-17
  • 打赏
  • 举报
回复
string[] aa = System.IO.Directory.GetFiles(Server.MapPath(Request.ApplicationPath+"/TestFolder/"), "a*.xls");
fanlly 2007-04-17
  • 打赏
  • 举报
回复
再顶!
fanlly 2007-04-17
  • 打赏
  • 举报
回复
自己顶!
fanlly 2007-04-17
  • 打赏
  • 举报
回复
问题没有解决,原因是这个功能是在一个DLL中实现的,而不是Web中。所以我把楼上的实现改为:
string[] aa = System.IO.Directory.GetFiles(System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath+"/TestFolder/","a*.xls");
但是,System.Web.HttpContext.Current报了空引用错误,高人费心了,请再指点指点,谢谢!

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧