制作内幕 游戏 网站 图标 | 理论 图标在线制作 | 看图软件 访谈活动 | 教程 技术 万年历
当前位置:首页>CG 教 程>网站开发>ASP.NET>

相关文章

推荐文章

     

热门文章

一个asp+ 版本的 Active Server Explorer

作者:CG谷 出处: 发布时间:2006-07-11 字体: [ ]

/*
豆腐制作 都是精品
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 下载
谢谢大家

作者:豆腐()


↑返回顶部   打印本页   关闭窗口↓  
收藏本文到:天极网摘 新浪VIVI 和讯网摘 博彩中心 365Key网摘 poco网摘 狐摘
亿友响享Yeeyoo igooi-it网摘 5seek网摘 I2Key 我摘网摘 天下图摘 YouNote 百特门
用户名: 新注册) 密码: 匿名评论 [所有评论]
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
设计服务 | 广告投放 | 友情链接 | 关于本站 | 联系我们 | 版权声明 | 设为首页 | 加入收藏