动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   .Net → 阅读文章

 一个asp+ 版本的 Active Server Explorer

作者来源: 
阅读 2929 人次 , 2000-12-4 

/*
豆腐制作 都是精品
http://www.asp888.net 豆腐技术站
如转载 请保留版权信息
*/
很多人可能都用过 chinaAsp 出的 ase 可以对 服务器上的文件进行各种操作,在这里我们也来
讲一个在 asp plus 下实现 ase 的程序 由于时间仓促 和本来就是 出于 演示的目的 本程序只演示了最简单的 情况 至于 上传 和编辑文本文件 我在 以前的文章里 都已经 讲过了,大家可以到 http://www.asp888.net 查看技术栏目里面的文章
首先是 列出 机器上 的盘符
<% @Page Language="C#" %>
<% @Import Namespace="System.IO" %>
<%
string[] LocalDriver = Directory.GetLogicalDrives();
int intNum = LocalDriver.Length;
Response.Write("<ul>");
for (int i=0; i < intNum; i++)
{
%>
<li><a href="dir.aspx?dir=<%=Server.UrlEncode(LocalDriver[i])%>"><%=LocalDriver[i]%></a></li>
<%
}
Response.Write("</ul>");
%>
列出所选择的盘符 上的目录
<% @Page Language="C#" %>
<% @Import Namespace="System.IO" %>
<%
string strDir2List = Server.UrlDecode(Request.QueryString.Get("dir"));
Directory thisOne = null;
try
{
thisOne = new Directory(strDir2List);
// 得到当前的目录创建时间
Response.Write("<p>当前所在目录: " + thisOne.ToString() + "</p>");
Directory[] Dir = thisOne.GetDirectories();
Response.Write("<ul>");
for (int i=0; i < Dir.Length; i++)
{
Response.Write("<li><a href=\"dir.aspx?dir=");
Response.Write(Server.UrlEncode(Dir[i].FullName));
Response.Write("\">" + Dir[i].Name);
Response.Write("</a><br>");
}
Response.Write("</ul>");

File[] Files = thisOne.GetFiles();
Response.Write("<ul>");
for (int i=0; i < Files.Length; i++)
{
Response.Write("<li><a href=\"viewfile.aspx?file=");
Response.Write(Server.UrlEncode(Files[i].FullName));
Response.Write("\">" + Files[i].Name);
Response.Write("</a><br>");
}
Response.Write("</ul>");
}
catch (Exception e)
{
Response.Write("错误: <i>");
Response.Write(e.ToString() + "</i>");
Response.End();
}
%>
查看文件的详细信息:
<% @Page Language=VB %>
<% @Import Namespace="System" %>
<% @Import Namespace="System.IO" %>
<html>
<head><title>编辑文件</title></head>
<body>
<%
dim File as string
File = Request.QueryString.Get("file")
thisOne = new File(File)
'string File = Request.QueryString.Get("file");
'File thisOne = new File(File);
%>
<table>
<tr><td>文件名称:</td><td><%=thisOne.Name%></td></tr>
<tr><td>文件的全名:</td><td><%=thisOne.FullName%></td></tr>
<tr><td>所在目录:</td><td><%=thisOne.DirectoryName%></td></tr>
<tr><td>文件创建时间:</td><td><%=thisOne.CreationTime.ToString()%></td></tr>
<tr><td>文件大小:</td><td><%=thisOne.Length.ToString()%> Bytes</td></tr>
<tr><td>最近一次的存取时间:</td><td><%=thisOne.LastAccessTime.ToString()%></td></tr>
<tr><td>最近一次更新时间:</td><td><%=thisOne.LastWriteTime.ToString()%></td></tr>
</table>
<%
ss=split(thisOne.Name,".")
fileent=lcase(ss(ubound(ss)))
if fileent="txt" or fileent="asp" or fileent="aspx" then
theReader = thisOne.OpenText()
Do
strIn = theReader.ReadLine()
response.write(strIn)
Loop Until strIn = Null

%>
<form action="savefile.asp" method=post>
<textarea cols=40 rows=30><%=strIn%></textarea>
<input type=hidden name=filename value="<%=thisOne.FullName%>">
<br>
<input type=submit value="保存更改">
</form>

<%
end if
%>
</body>
</html>
好了一个完整的 ase 程序还需要 删除 拷贝 移动和上传 编辑 相信大家在 看完这个程序以后 一定会 有办法 经过 简单 的改动 就 可以实现
这个程序的完整例子可以在 http://www.asp888.net/download/asp/ase.zip 下载
谢谢大家

作者:豆腐()


  

 本文TagsC#  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:asp+中的session 的使用和原理() 不需要cookie也可以使用session
· 下一篇:妙用asp+的global.asax
· ASP.NET创建XML Web服务全接触(4)
· 多中WEB服务器的通用JSp源代码暴露漏洞
· 从ASP迁移至ASP+ --将HTML表格转换为ASP+数据列表
· 是否能让JAVA 和 .NET框架共存
· VB.NET如何在没有.NET框架的机器上运行


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077