广州华美达广场酒店:100分问关于asp删除目录的问题

来源:百度文库 编辑:高考问答 时间:2024/04/29 21:43:57
一组access数据库记录,记录了很多磁盘上了目录列表

比如有一组目录folder1、folder2、folder_abc……目录名称是没有规律的

可能folder1在D盘,folder2在E盘,folder_abc在F盘……

现在我想实现选择任何一个或多个目录批量删除,并且删除过程中有文本提示:当前正在删除***目录,这样的语句该怎样写?

我只知道删除单个的目录的fso语句是:DeleteFolder

问题解决了我再加分!谢谢!
删除不单只是删除数据库记录,也要删除对应的所在文件夹

我知道利用id号实现批量删除,但不能删除对应的目录,有一个难点就是,这些目录不是在同一个位置.如果是同一个位置就好办了

WEB ftp只是直接管理磁盘文件,磁盘文件并没有存入数据库

能不能给具体些代码?

下面是我收集的一些代码。这个代码的功能是使用FSO按文件大小浏览文件目录并进行删除操作。
我想你用一个循环读取数据库的目录并显示,然后选择需要删除的目录或文件。有必要的话同时删除数据库记录。
至于删除过程中显示文本提示,这个比较简单。应该可以实现

<%@ Language=VBScript %>
<%Server.ScriptTimeout=50000%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
<%
function JudgeParaRegular(intID)
if intID<>"" and isnumeric(intID) then
JudgeParaRegular=intId
else
Response.Write "输入错误!"
Response.End
end if
end function
intFileSize=JudgeParaRegular(Request.QueryString("intFileSize"))
strPath=Request.QueryString("strPath")
if instr(strPath,":")=0 then strPath=server.MapPath(strPath)
%>
<%
function deletefiles(path)
on error resume next
Set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FileExists(path) then
fs.DeleteFile path,True
response.write "成功删除"&path
else
response.write "文件不存在!"
end if
Set fs=nothing
if Err.number<>0 then Response.Write Err.number
end function
strFile=request("strFile")
if request("strFile")<>"" then
deletefiles strFile
end if

%>

<%
function ListFolderFiles(strPath,intFileSize,intFlag)
strOriginPath= Request.ServerVariables("Script_Name")& "?strPath=" &Request.QueryString("strPath") & "&intFileSize="&Request.QueryString("intFileSize")
if strPath<>"" then
if intFlag=0 then
intFlag=intFlag+1
end if
Set objFs=Server.CreateObject("Scripting.FileSystemObject")
Set objFdir=objFs.GetFolder(strPath)
strParentPath= objFs.GetParentFolderName(strPath)
for each strSubFiles in objFdir.files
if strSubFiles.size /(1024^2)>=intFileSize then
Response.Write "<TR>" & vbcrlf
Response.Write "<TD>" & replace(strNullTran(strSubFiles),strNullTran(strSubFiles.Name),"<b>"&strNullTran(strSubFiles.Name)&"</b>") & "</TD>" & vbcrlf
Response.Write "<TD>"& strNullTran(FormatNumber(strSubFiles.size /(1024^2),2)) &" MB</TD>" & vbcrlf
Response.Write "<TD>" & strNullTran(strSubFiles.type) & "</TD>" & vbcrlf
Response.Write "<TD>" & strNullTran(strSubFiles.datelastmodified) & "</TD>" & vbcrlf
Response.Write "<TD><A HREF='"& strOriginPath & "&strFile="&strNullTran(strSubFiles)&"'><img align=absmiddle border=0 src='images/delete.gif'></A></TD>" & vbcrlf
Response.Write "</TR>" & vbcrlf
intFlag=intFlag+strSubFiles.size
end if
next
for each strSubFolders in objFdir.SubFolders
if intFlag=0 then intFlag=1
ListFolderFiles strSubFolders,intFileSize,intFlag
next
else
Response.Write "<tr><td colspan=5>输入错误!</td></tr>"
end if
ListFolderFiles=intFlag
end function
function strNullTran(str)
if isnull(str) or str="" then
strNullTran=" "
else
strNullTran=str
end if
end function
Response.Write "<TABLE WIDTH=100% BORDER=1 CELLSPACING=1 CELLPADDING=1>" & vbcrlf
Response.Write "<TR>" & vbcrlf
Response.Write "<TD>文件名及路径</TD>" & vbcrlf
Response.Write "<TD align=center>大小</TD>" & vbcrlf
Response.Write "<TD align=center>类别</TD>" & vbcrlf
Response.Write "<TD align=center>修改时间</TD>" & vbcrlf
Response.Write "<TD align=center>删除</TD>" & vbcrlf
Response.Write "</TR>" & vbcrlf
intFlag=ListFolderFiles(strPath,CDbl(intFileSize),0)
Response.Write "<tr><td align=right>总计:</td><td colspan=4>"&formatNumber((intFlag-1)/(1024^2),2) &" MB</td></tr>" & vbcrlf
Response.Write "</TABLE>" & vbcrlf
%>
</BODY>
</HTML>

去下载个WEB版的FTP自己去研究吧 很简单的东西里边有创建删除等有你要的所有东西都是用的FSO

怎么感觉你的问题应该使用应用程序去解决啊!!

WEB版的FTP程序也不错!建议使用

用循环来帮呗,
for i=1 to 所有文件夹个数
response.write("正在删除第"&i&"个。。。。")
deletefolder
next

我没有做过
不过我想应该是有个内置对象
通过
for each subObject in Object
\"delete\" subObject
next
就可以了

上网下个asp做的文件管理程序 来参考

fso有足够的能力管理整个文件系统

首先要访问要删除的目录 (网上的asp程序可供参考)访问的同时
将要删除的文件路径存储在session或cookie等全局变量中
选择完后统一的delete这样就可以达到批量操作的目的