28,408
社区成员
发帖
与我相关
我的任务
分享<%
dim fs
dim bojFolder
dim path
path=server.mappath("总文件夹")
Set fs = CreateObject("Scripting.FileSystemObject")
set objFolder=fs.GetFolder(path)
set objSubFolders=objFolder.Subfolders
for each objSubFolder in objsubfolders
folderpath=path + "\" +objSubFolder.name
call deletefolder(folderpath)
call createfolder(folderpath)
next
sub Deletefolder(Path)
If fs.folderExists(Path) Then
fs.Deletefolder(Path)
End If
End sub
sub createfolder(Path)
if not fs.FolderExists(Path) then
fs.CreateFolder(Path)
end if
end sub
set fs=nothing
%>
<%
DelAllInFolder server.MapPath("总")
'/////////////// 删除函数 /////////////////////////
Sub DelAllInFolder(ByVal strFolder)'flag 1-保留个人文件夹 0--其他
On Error Resume Next
s="张三,李四,王五,赵六"
Dim fso,objFolder,TempFolder, SubSubFolders, objFiles,objFile
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(strFolder)
Set SubSubFolders = objFolder.SubFolders
Set objFiles = objFolder.Files
'---------删除文件夹
For Each TempFolder In SubSubFolders
if instr(s,TempFolder.Name)=0 then
TempFolder.Delete True
else
DelAllInFolder server.MapPath("总/"&TempFolder.Name)
end if
Next
'---------删除根目录下文件
For Each objFile In objFiles
objFile.Delete True
Next
Set objFolder = nothing
Set SubSubFolders = nothing
Set objFiles = nothing
Set fso = nothing
end sub
%>
function Del(RootStr)
dim fso
set fso=server.CreateObject("Scripting.FileSystemObject")
dim RootPath:RootPath=server.MapPath(RootStr)
dim Rootfolder:set Rootfolder=fso.GetFolder(RootPath)'1级
dim folders:set folders=Rootfolder.subfolders'2级
dim fds,fls
for each fd in folders
set fds=fd.subfolders
set fls=fd.files
for each fd3 in fds
fd3.delete(true)'删除3级以上的文件夹
next
for each fl3 in fls
fl3.delete(true)'删除处于3级的文件
next
set fsd=nothing
set fls=nothing
next
set folders=nothing
set Rootfolder=nothing
set fso=nothing
end function
Del("总文件夹")
<%dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
sub Deletefolder(Path)
If fs.folderExists(Path) Then
fs.Deletefolder(Path)
End If
End sub
sub createfolder(Path)
if not fs.FolderExists(Path) then
fs.CreateFolder(Path)
end if
end sub
sub dealfolder(Path,toLevel,cLevel)
dim folder,n
for each folder in fs.GetFolder(Path).SubFolders
n=cLevel+1
if n=toLevel then
fs.Deletefolder(folder)
else
call dealfolder(folder,toLevel,n)
end if
next
end sub
call dealfolder(server.mappath("总文件夹"),3,0)
'dim path,arry,i
'arry=split("张三,李四,王五,赵六",",")
'path=server.mappath("总文件夹")
'call Deletefolder(path)
'call createfolder(path)
'for i=0 to ubound(arry)
' call createfolder(path &"/" & arry(i) &"文件夹")
'next
'set fs=nothing%>
<%
dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
sub Deletefolder(Path)
If fs.folderExists(Path) Then
fs.Deletefolder(Path)
End If
End sub
sub createfolder(Path)
if not fs.FolderExists(Path) then
fs.CreateFolder(Path)
end if
end sub
dim path,arry,i
arry=split("张三,李四,王五,赵六",",")
path=server.mappath("总文件夹")
call Deletefolder(path)
call createfolder(path)
for i=0 to ubound(arry)
call createfolder(path &"/" & arry(i) &"文件夹")
next
set fs=nothing
%>