您的位置:首页网页设计ASP实例 → 查看服务器磁盘、文件的aspx.

查看服务器磁盘、文件的aspx.

时间:2004/11/7 2:53:00来源:本站整理作者:蓝点我要评论(0)

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("
");

Response.Write("您的可用内存是:");

Response.Write(qmo);

Response.Write("
");

Response.Write("自上次重启已经有");

Response.Write(qtick.ToString());

Response.Write("分钟了");

Response.Write("
");

Response.Write("
");

Response.Write("
");

Response.Write("查看你的磁盘:");



Response.Write("

");


for (int i=0; i < nNumOfDrives; i++)


{


    Response.Write("

<a href=\"listdir.aspx?dir=");

    Response.Write(Server.UrlEncode(achDrives[i]));

    Response.Write("\">" + achDrives[i]);

    Response.Write("
");

}

Response.Write("

");

%>





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("

创建时间: " + thisOne.CreationTime.ToString() + "

");

        Directory[] subDirectories = thisOne.GetDirectories();

    Response.Write("

");


    Response.Write("-------------------------------文件夹-------------------------");


    Response.Write("

 

");


    for (int i=0; i < subDirectories.Length; i++)


    {


        Response.Write("

<a href=\"listdir.aspx?dir=");

        Response.Write(Server.UrlEncode(subDirectories[i].FullName));

        Response.Write("\">" + subDirectories[i].Name);

        Response.Write("
");

    }

    Response.Write("

");

    

    File[] theFiles = thisOne.GetFiles();

    Response.Write("

");


    Response.Write("-------------------------------文件----------------------------");


    Response.Write("

 

");


    for (int i=0; i < theFiles.Length; i++)


    {


        Response.Write("

<a href=\"showfile.aspx?file=");

        Response.Write(Server.UrlEncode(theFiles[i].FullName));

        Response.Write("\">" + theFiles[i].Name);

        Response.Write("
");

    }

    Response.Write("

");

}

catch (Exception e)

{

    Response.Write("由于以下原因无法实现此功能: ");

    Response.Write(e.ToString() + "");

    Response.End();

}

%>





showfile.aspx





<% page="" language="C#" debug="true">

<% import="" namespace="System.IO">


File Info





<%

string strFile2Show = Request.QueryString.Get("file");

File thisOne = new File(strFile2Show);

%>














文件名:
<%=thisone.name%>
全名:
<%=thisone.fullname%>
文件创建日期:
<%=thisone.creationtime.tostring()%>
文件大小:
<%=thisone.length.tostring()%> Bytes
上次使用时间:
<%=thisone.lastaccesstime.tostring()%>
上次修改时间:
<%=thisone.lastwritetime.tostring()%>





<%

StreamReader theReader = thisOne.OpenText();

char[] theBuffer = new char[1000];

int nRead = theReader.ReadBlock(theBuffer, 0, 1000);

Response.Write("
");

Response.Write(" 文件内容预览:");

Response.Write("
");

Response.Write("

 

"); Response.Write(Server.HtmlEncode(new String(theBuffer,0,nRead))); Response.Write("

 

");

%>









正在丰富成管理用,整合上传,修改,删除等管理功能

不知有没有这么多时间了

努力吧,朋友

相关阅读 Mac和Windows哪个好 windows和mac os对比介绍Win10预览版怎么升级 Win10预览版升级方法厂商不再预装Win7或8.1系统,驱动人生帮您快速升级Mac移动硬盘安装win8 Mac将win装在移动硬盘使用教程windows10xboxone串流简单教程Windows Hello怎么用 Windows Hello使用设置教程win10怎么关闭自动更新 win10如何关闭自动更新Mac系统如何远程桌面到Windows系统

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 迅雷新手完全入门手册 asp下面javascript上传图片限制格式大小方法告诉大家网页弹出窗口应用总结ASP常见错误类型大全asp常见错误分析和解决办法

人气排行 总是弹出visual studio 实时调试器 三种解决SQLSERVER存储过程及调用详解Asp获取真实IP地址ASP中连接Mssql的几种方法一个简单好用的UBB编辑器(含代码)如何用Split将字符串转换为数组并获取数组下ASP防止表单重复提交的办法告诉你免费的简单聊天室源代码