康柏仕电脑学院Microsoft Windows交流平台Dreamweaver网站设计交流区 → ASP文件管理简单示例


  共有13247人关注过本帖树形打印复制链接

主题:ASP文件管理简单示例

帅哥哟,离线,有人找我吗?
轻轻风聆
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 家人主人
等级:管理员 帖子:2674 积分:26165 威望:0 精华:14 注册:2005/9/15
ASP文件管理简单示例  发帖心情 Post By:2008/11/28 13:37:29 [只看该作者]

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
act=request("act")
select case act
case "del"
Del()
case else
Show()
end select
function Del()
files=trim(request("fs"))
files=replace(files,",",":")
files=replace(files,",","\")
on error resume next
Set Sys = Server.CreateObject("Scripting.FileSystemObject")
If Sys.FileExists(files) Then
    Sys.DeleteFile(files)
end if
if err then
   response.write "<script>alert('无法删除指定文件,请联系管理员以手动方式删除!');window.history.back();</script>"
else
   response.write "<script>alert('文件删除成功!');window.location='filemanage.asp';</script>"
end if
end function
function Show()
fs=request("fs")
if fs<>"" then
   folderspec=fs&"\"
else
   folderspec="E:\WebSite\"
end if
'锁定目录
if len(folderspec)<len("E:\WebSite\") then
   folderspec="E:\WebSite\"
end if
set fs=createobject("scripting.filesystemobject")
set f=fs.getfolder(folderspec)
set fd=f.subfolders
%>
<link href="cssStyle/main.css" rel="stylesheet" type="text/css">
<style>
body
{
background-color:#FFFFFF;
}
</style>
<table width="100%" border="1" align="center" cellpadding="2" cellspacing="0" bordercolorlight="#555555" bordercolordark="#F3F3F3">
   <tr>
   <td height="25" bgcolor="#ECE9D8">当前路径:<%=folderspec%></td>
   </tr>
</table>
<table width="100%" border="1" align="center" cellpadding="2" cellspacing="0" bordercolorlight="#555555" bordercolordark="#F3F3F3">
<tr>
   <th height="23" colspan="2">文件名</th>
   <th>文件大小</th>
   <th>文件类型</th>
   <th>创建日期</th>
   <th>文件管理</th>
   </tr>
<%
for each whatever in fd
%>
   <tr >
   <td width="23" height="23"><a href="filelist.asp?fs=<%=folderspec%>&<%=whatever.name%>"><img src="images/folder.gif" width="20" height="20" border="0"></td>
   <td><a href="?fs=<%=folderspec&whatever.name%>"><%=whatever.name%></a></td>
   <td><%=whatever.size%></td>
   <td><%=whatever.type%></td>
   <td><%=whatever.DateCreated %></td>
   <td>&nbsp;</td>
   </tr>
<%next
set fc=f.files
for each whatever in fc
%>
   <tr >
   <td width="23" height="23"><a href="filelist.asp?fs=<%=folderspec%>&<%=whatever.name%>"><img src="images/file.gif" width="20" height="20" border="0"></td>
   <td height="23"><%=whatever.name%></td>
   <td><%=int(whatever.size/1024)+1%> KB</td>
   <td><%=whatever.type%></td>
   <td><%=whatever.DateCreated %></td>
   <td>
   <%
    url=replace(folderspec,"E:\WebSite\","")
    url=replace(url,"\","/")
    fos=replace(folderspec&whatever.name,"\",",")
    fos=replace(fos,":",",")
   %>
   <a href="http://www.xxx.com/<%=url%><%=whatever.name%>" target="_blank">查看</a> | <a href="#" >删除</a>
   </td>
   </tr>
<%
next
%>
</table>
<table width="100%" border="1" align="center" cellpadding="2" cellspacing="0" bordercolorlight="#555555" bordercolordark="#F3F3F3">
   <tr>
   <td height="25" bgcolor="#FFFFFF">
   <%
   str="?fs="&folderspec
   If InstrRev(str, "\") > 1 Then
    str=Left(str, InstrRev(str, "\") - 1)
   End If
   If InstrRev(str, "\") > 1 Then
    str=Left(str, InstrRev(str, "\") - 1)
   End If
   %>
   <a href="<%=str%>">返回上一级</a></td>
   </tr>
</table>
<%end function%>


正航--放大你管理的力量!
正航,缔造智慧企业!
正航东莞-松山湖、长安:www.chidg.com
咨询热线:0769-81158210  13580877608
 回到顶部
帅哥哟,离线,有人找我吗?
轻轻风聆
  2楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 家人主人
等级:管理员 帖子:2674 积分:26165 威望:0 精华:14 注册:2005/9/15
  发帖心情 Post By:2008/11/28 13:37:47 [只看该作者]

<%  
  Set   FSO   =   Server.CreateObject("Scripting.FileSystemObject")  
  Set   Files   =   FSO.GetFile("c:\HONDA.jpg")  
  %>  
  <font   color=red>[<%=Files.Name%>]</font>文件的全部属性:  
  <Br>名称:<%=Files.Name   %>  
  <Br>路径:<%=Files.Path   %>  
  <Br>驱动器:<%=Files.Drive   %>  
  <Br>大小:<%=Files.size   %>  
  <Br>类型:<%=Files.type   %>  
  <Br>属性:<%=Files.Attributes   %>  
  <Br>创建日期:<%=Files.DateCreated   %>  
  <Br>上次进入日期:<%=Files.DateLastAccessed   %>  
  <Br>上次修改日期:<%=Files.DateLastModified   %>  
  <br>文件的父文件夹:<%=Files.ParentFolder%>  
  <br>文件短文件名:<%=Files.ShortName%>  
  <br>短路径名:<%=Files.ShortPath%>

[此贴子已经被作者于2008-11-28 13:37:57编辑过]


正航--放大你管理的力量!
正航,缔造智慧企业!
正航东莞-松山湖、长安:www.chidg.com
咨询热线:0769-81158210  13580877608
 回到顶部
帅哥哟,离线,有人找我吗?
tom100
  3楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:8 积分:88 威望:0 精华:0 注册:2009/1/18 18:18:43
  发帖心情 Post By:2009/2/24 11:59:32 [只看该作者]

顶!支持一下!!:)

____________________
812-632 01 812-632 02
812-632 03 812 01
812 02 cell phone search

 


 回到顶部