• 全部
  • .NET Framework
  • ASP
  • Web Services
  • .NET互联网桌面应用
  • VB
  • 图表区
  • 分析与设计
  • 组件/控件开发
  • AppLauncher
  • 问答

重载的时候为什么不能获取参数。。。(重载Directory)

lgk1012 2005-02-07 12:09:00
<% @Page Language="C#" %>
<% @Import Namespace="System.IO" %>
<%
string strDir2List=Request.QueryString.Get("dir");
Directory thisOne=null;
try
{
thisOne=new Directory(strDir2List);
Response.Write("<p>Creation:"+thisOne.CreationTime.ToString()+"</p>");
Directory[] subDirectories=thisOne.GetDirectories();
Response.Write("<ul>");
for (int i=0;i<subDirectories.Length;i++)
{
Response.Write("<li><a href=\"listdir.aspx?dir=");
Response.Write(Server.UrlEncode(subDirectories[i].FullName));
Response.Write("\">"+subDirectories[i].Name);
Response.Write("</a><br>");
}
Response.Write("</ul>");
File[] theFiles=thisOne.GetFiles();
Response.Write("<ul>");
for(int i=0;i<theFiles.Length;i++)
{
Response.Write("<li><a href=\"showfile.aspx?file=");
Response.Write(Server.UrlEncode(theFiles[i].FullName));
Response.Write("\">"+theFiles[i].Name);
Response.Write("</a><br>");
}
Response.Write("</ul>");
}
catch (Exception e)
{
Response.Write("Access not possible,error:<i>");
Response.Write(e.ToString()+"</i>");
Response.End();
}
%>
...全文
37 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
lgk1012 2005-02-09
问题以解决,谢谢!
回复
mornove 2005-02-07
我也在找答案,高手谢谢你了
回复
wj2929 2005-02-07
完整如下:
.........
DirectoryInfo thisOne=null;
try
{
thisOne=new DirectoryInfo(strDir2List);
Response.Write("<p>Creation:"+thisOne.CreationTime.ToString()+"</p>");
DirectoryInfo[] subDirectories=thisOne.GetDirectories();
Response.Write("<ul>");
for (int i=0;i<subDirectories.Length;i++)
{
Response.Write("<li><a href=\"listdir.aspx?dir=");
Response.Write(Server.UrlEncode(subDirectories[i].FullName));
Response.Write("\">"+subDirectories[i].Name);
Response.Write("</a><br>");
}
Response.Write("</ul>");
FileInfo[] theFiles=thisOne.GetFiles();
Response.Write("<ul>");
for(int i=0;i<theFiles.Length;i++)
{
Response.Write("<li><a href=\"showfile.aspx?file=");
Response.Write(Server.UrlEncode(theFiles[i].FullName));
Response.Write("\">"+theFiles[i].Name);
Response.Write("</a><br>");
}
Response.Write("</ul>");
}
catch (Exception e)
{
Response.Write("Access not possible,error:<i>");
Response.Write(e.ToString()+"</i>");
Response.End();
}
...............
回复
wj2929 2005-02-07
使用DirectoryInfo而非Directory
回复
相关推荐
发帖
.NET技术社区
创建于2007-09-28

5.8w+

社区成员

.NET技术交流专区
申请成为版主
帖子事件
创建了帖子
2005-02-07 12:09
社区公告
暂无公告