Rss & SiteMap

康柏仕电脑学院 index.asp

康柏仕电脑学院--台湾正航ERP软件售后技术论坛,客服热线0769-81158210
共3 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

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

1楼
轻轻风聆 发表于: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%>
2楼
轻轻风聆 发表于: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编辑过]
3楼
tom100 发表于:2009/2/24 11:59:32

顶!支持一下!!:)

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

 

共3 条记录, 每页显示 10 条, 页签: [1]

Copyright ©2005 - 2024 康柏仕电脑学院 清理缓存

正航ERP软件-企业ERP最佳选择! http://www.chidg.com  0769-81158210
Powered By Dvbbs Version 8.3.0
Processed in .01563 s, 2 queries.