查看服務(wù)器磁盤、文件的aspx
發(fā)表時(shí)間:2024-05-14 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]listdrives.aspx <% @Page Language="C#" %><% @Import Namespace="System" %><% @Import Namespace="System.IO"...
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("您的系統(tǒng)是:");
Response.Write(qdrives);
Response.Write("<br>");
Response.Write("您的可用內(nèi)存是:");
Response.Write(qmo);
Response.Write("<br>");
Response.Write("自上次重啟已經(jīng)有");
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>創(chuàng)建時(shí)間: " + 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("由于以下原因無法實(shí)現(xiàn)此功能: ");
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>文件創(chuàng)建日期:</td><td><%=thisOne.CreationTime.ToString()%></td></tr>
<tr><td>文件大。</td><td><%=thisOne.Length.ToString()%> Bytes</td></tr>
<tr><td>上次使用時(shí)間:</td><td><%=thisOne.LastAccessTime.ToString()%></td></tr>
<tr><td>上次修改時(shí)間:</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(" 文件內(nèi)容預(yù)覽:");
Response.Write("<br>");
Response.Write("<pre>");
Response.Write(Server.HtmlEncode(new String(theBuffer,0,nRead)));
Response.Write("</pre>");
%>
</body>
</html>
正在豐富成管理用,整合上傳,修改,刪除等管理功能
不知有沒有這么多時(shí)間了
努力吧,朋友