listdrives.aspx
<% @page language="c#" %>
<% @import namespace="system" %>
<% @import namespace="system.io" %>
<%
string qdrives = environment.osversion.tostring();
string qnewline=environment.systemdirectory.tostring();
string qmo=environment.workingset.tostring();
int qtick=environment.tickcount;
qtick/=60000;
string[] achdrives = directory.getlogicaldrives();
int nnumofdrives = achdrives.length;
response.write("您的系统是:");
response.write(qdrives);
response.write("<br>");
response.write("您的可用内存是:");
response.write(qmo);
response.write("<br>");
response.write("自上次重启已经有");
response.write(qtick.tostring());
response.write("分钟了");
response.write("<br>");
response.write("<br>");
response.write("<br>");
response.write("查看你的磁盘:");
response.write("<ul>");
for (int i=0; i < nnumofdrives; i++)
{
response.write("<li><a href=/"listdir.aspx?dir=");
response.write(server.urlencode(achdrives[i]));
response.write("/">" + achdrives[i]);
response.write("</a><br>");
}
response.write("</ul>");
%>
listdir.aspx
<% @page language="c#" debug="true" %>
<% @import namespace="system.io" %>
<%
string strdir2list = request.querystring.get("dir");
directory thisone = null;
try
{
thisone = new directory(strdir2list);
// auslesen der eigenschaften der verzeichnisses
response.write("<p>创建时间: " + thisone.creationtime.tostring() + "</p>");
directory[] subdirectories = thisone.getdirectories();
response.write("<ul>");
response.write("-------------------------------文件夹-------------------------");
response.write("<br>");
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>");
response.write("-------------------------------文件----------------------------");
response.write("<br>");
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("由于以下原因无法实现此功能: ");
response.write(e.tostring() + "");
response.end();
}
%>
showfile.aspx
<% @page language="c#" debug="true"%>
<% @import namespace="system.io" %>
<html>
<head><title>file info</title></head>
<body>
<%
string strfile2show = request.querystring.get("file");
file thisone = new file(strfile2show);
%>
<table>
<tr><td>文件名:</td><td><%=thisone.name%></td></tr>
<tr><td>全名:</td><td><%=thisone.fullname%></td></tr>
<tr><td>文件创建日期:</td><td><%=thisone.creationtime.tostring()%></td></tr>
<tr><td>文件大小:</td><td><%=thisone.length.tostring()%> bytes</td></tr>
<tr><td>上次使用时间:</td><td><%=thisone.lastaccesstime.tostring()%></td></tr>
<tr><td>上次修改时间:</td><td><%=thisone.lastwritetime.tostring()%></td></tr>
</table>
<%
streamreader thereader = thisone.opentext();
char[] thebuffer = new char[1000];
int nread = thereader.readblock(thebuffer, 0, 1000);
response.write("<br>");
response.write(" 文件内容预览:");
response.write("<br>");
response.write("<pre>");
response.write(server.htmlencode(new string(thebuffer,0,nread)));
response.write("</pre>");
%>
</body>
</html>
正在丰富成管理用,整合上传,修改,删除等管理功能
不知有没有这么多时间了
努力吧,朋友
新闻热点
疑难解答