<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<%@Import Namespace="System.IO"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ListDrives</title>
</head>
<%
string[] achDrives=Directory.GetLogicalDrives();
int nNumOfDrives=achDrives.Length;
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>");
%>
<body>
</body>
</html>
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<%@Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>listdir</title>
</head>
<%
string strDir2List=Request.QueryString.Get("dir");
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=/"showfiles.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();
}
%>
<body>
</body>
</html>
<%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
<% @Import Namespace="System.IO"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>showfiels</title>
</head>
<body>
<%
string strFile2Show=Request.QueryString.Get("file");
FileInfo thisOne=new FileInfo(strFile2Show);
%>
<table>
<tr><td>Name:</td><td><%=thisOne.Name%></td></tr>
<tr><td>Path:</td><td><%=thisOne.FullName%></td></tr>
<tr><td>Directory:</td><td><%=thisOne.DirectoryName%></td></tr>
<tr>
<td>Date Created:</td>
</tr>
<tr>
<td>Size:</td>
<td><%=thisOne.Length.ToString()%>Bytes</td>
</tr>
<tr>
<td>Last access:</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[255];
int nRead=theReader.ReadBlock(theBuffer,0,255);
Response.Write("<pre>");
Response.Write(Server.HtmlEncode(new string(theBuffer,0,nRead)));
Response.Write("</pre>");
%>
</body>
</html>