View the server disk, ASPX for the file.

Source: Internet
Author: User
Tags file info file size tostring urlencode
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 ("Your system is:");
Response.Write (qdrives);
Response.Write ("<br>");
Response.Write ("Your Available memory is:");
Response.Write (QMO);
Response.Write ("<br>");
Response.Write ("Since the last reboot has been");
Response.Write (Qtick. ToString ());
Response.Write ("Minutes");
Response.Write ("<br>");
Response.Write ("<br>");
Response.Write ("<br>");
Response.Write ("View your disk:");

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> creation Time:" + thisOne.CreationTime.ToString () + "</p>");
directory[] subdirectories = Thisone.getdirectories ();
Response.Write ("<ul>");
Response.Write ("-------------------------------folder-------------------------");
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 ("-------------------------------document----------------------------");
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 ("This feature cannot be implemented for the following reasons:");
Response.Write (e.tostring () + "");
Response.End ();
}
%>


Showfile.aspx


<% @Page language= "C #" debug= "true"%>
<% @Import namespace= "System.IO"%>
<body>
<%
String strfile2show = Request.QueryString.Get ("file");
File Thisone = new file (strfile2show);
%>
<table>
<tr><td> filename:</td><td><%=thisone.name%></td></tr>
<tr><td> Full Name:</td><td><%=thisone.fullname%></td></tr>
<tr><td> File Creation Date: </td><td><%=thisone.creationtime.tostring ()%></td></tr >
<tr><td> File Size: </td><td><%=thisone.length.tostring ()%> bytes</td></tr>
<tr><td> last used time: </td><td><%=thisone.lastaccesstime.tostring ()%></td></tr >
<tr><td> Last modified: </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 ("File content preview:");
Response.Write ("<br>");
Response.Write ("<pre>");
Response.Write (Server.HTMLEncode) (New String (Thebuffer,0,nread));
Response.Write ("</pre>");
%>

</body>

is enriching into management, integration upload, modify, delete and other management functions
I don't know if I've got that much time.
Work hard, my friend.
Turn from: Dynamic Network production guide www.knowsky.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.