- 爱易网页
-
ASP教程
- 查看服务器磁盘、文件的aspx.
日期:2011-01-31 浏览次数:20896 次
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
<
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。