asp下利用fso實(shí)現(xiàn)文件夾或文件移動(dòng)改名等操作函數(shù)
更新時(shí)間:2008年01月12日 16:18:47 作者:
以后利用fso來操作文件和文件夾就方便了
asp利用fso實(shí)現(xiàn)文件的移動(dòng)
function movefiles(sFolder,dFolder)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sFolder)) and fso.folderexists(server.mappath(dFolder)) then
fso.copyfolder server.mappath(sFolder),server.mappath(dFolder)
movefiles = true
else
movefiles = false
set fso = nothing
call alertbox("系統(tǒng)沒有找到指定的路徑[" & sFolder & "]!",2)
end if
set fso = nothing
end function
asp修改文件夾名稱
function renamefolder(sFolder,dFolder)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sFolder)) then
fso.movefolder server.mappath(sFolder),server.mappath(dFolder)
renamefolder = true
else
renamefolder = false
set fso = nothing
call alertbox("系統(tǒng)沒有找到指定的路徑[" & sFolder & "]!",2)
end if
set fso = nothing
end function
asp檢查文件夾是否存在
function checkfolder(sPATH)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sPATH)) then
checkfolder = true
else
checkfolder = false
end if
set fso = nothing
end function
asp檢查文件是否存在
function checkfile(sPATH)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.fileexists(server.mappath(sPATH)) then
checkfile = true
else
checkfile = false
end if
set fso = nothing
end function
asp創(chuàng)建文件夾
function createdir(sPATH)
dim fso,pathArr,i,path_Level,pathTmp,cPATH
on error resume next
sPATH = replace(sPATH,"\","/")
set fso = server.createobject("scripting.filesystemobject")
pathArr = split(sPATH,"/")
path_Level = ubound(pathArr)
for i = 0 to path_Level
if i = 0 then pathTmp = pathArr(0) & "/" else pathTmp = pathTmp&pathArr(i) & "/"
cPATH = left(pathTmp,len(pathTmp)-1)
if not fso.folderexists(cPATH) then fso.createfolder(cPATH)
next
set fso = nothing
if err.number <> 0 then
err.clear
createdir = false
else
createdir = true
end if
end function
刪除文件夾,這里是刪除系統(tǒng)中欄目的文件夾
function delclassfolder(sPATH)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sPATH)) then
fso.deletefolder(server.mappath(sPATH))
end if
set fso = nothing
end function
刪除新聞內(nèi)容文件
function delnewsfile(sPATH,filename)
on error resume next
dim fso,tempArr,cPATH,ePATH,i:i = 0
set fso = server.createobject("scripting.filesystemobject")
sPATH = sPATH & filename & site_extname
if fso.fileexists(server.mappath(sPATH)) then
fso.deletefile(server.mappath(sPATH))
while(i <> -1)
i = i + 1
ePATH = replace(sPATH,filename & ".",filename & "_" & i + 1 & ".")
if fso.fileexists(server.mappath(ePATH)) then
fso.deletefile(server.mappath(ePATH))
else
i = -1
end if
wend
end if
end function
function movefiles(sFolder,dFolder)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sFolder)) and fso.folderexists(server.mappath(dFolder)) then
fso.copyfolder server.mappath(sFolder),server.mappath(dFolder)
movefiles = true
else
movefiles = false
set fso = nothing
call alertbox("系統(tǒng)沒有找到指定的路徑[" & sFolder & "]!",2)
end if
set fso = nothing
end function
asp修改文件夾名稱
function renamefolder(sFolder,dFolder)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sFolder)) then
fso.movefolder server.mappath(sFolder),server.mappath(dFolder)
renamefolder = true
else
renamefolder = false
set fso = nothing
call alertbox("系統(tǒng)沒有找到指定的路徑[" & sFolder & "]!",2)
end if
set fso = nothing
end function
asp檢查文件夾是否存在
function checkfolder(sPATH)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sPATH)) then
checkfolder = true
else
checkfolder = false
end if
set fso = nothing
end function
asp檢查文件是否存在
function checkfile(sPATH)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.fileexists(server.mappath(sPATH)) then
checkfile = true
else
checkfile = false
end if
set fso = nothing
end function
asp創(chuàng)建文件夾
function createdir(sPATH)
dim fso,pathArr,i,path_Level,pathTmp,cPATH
on error resume next
sPATH = replace(sPATH,"\","/")
set fso = server.createobject("scripting.filesystemobject")
pathArr = split(sPATH,"/")
path_Level = ubound(pathArr)
for i = 0 to path_Level
if i = 0 then pathTmp = pathArr(0) & "/" else pathTmp = pathTmp&pathArr(i) & "/"
cPATH = left(pathTmp,len(pathTmp)-1)
if not fso.folderexists(cPATH) then fso.createfolder(cPATH)
next
set fso = nothing
if err.number <> 0 then
err.clear
createdir = false
else
createdir = true
end if
end function
刪除文件夾,這里是刪除系統(tǒng)中欄目的文件夾
function delclassfolder(sPATH)
on error resume next
dim fso
set fso = server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(sPATH)) then
fso.deletefolder(server.mappath(sPATH))
end if
set fso = nothing
end function
刪除新聞內(nèi)容文件
function delnewsfile(sPATH,filename)
on error resume next
dim fso,tempArr,cPATH,ePATH,i:i = 0
set fso = server.createobject("scripting.filesystemobject")
sPATH = sPATH & filename & site_extname
if fso.fileexists(server.mappath(sPATH)) then
fso.deletefile(server.mappath(sPATH))
while(i <> -1)
i = i + 1
ePATH = replace(sPATH,filename & ".",filename & "_" & i + 1 & ".")
if fso.fileexists(server.mappath(ePATH)) then
fso.deletefile(server.mappath(ePATH))
else
i = -1
end if
wend
end if
end function
相關(guān)文章
asp下取得客戶端IP地址函數(shù) 轉(zhuǎn)換IP地址函數(shù)
asp下取得客戶端IP地址函數(shù) 轉(zhuǎn)換IP地址函數(shù)...2007-08-08用QuickWAP組件結(jié)合ASP建設(shè)Wap站點(diǎn)
用QuickWAP組件結(jié)合ASP建設(shè)Wap站點(diǎn)...2007-03-03asp實(shí)現(xiàn)防止從外部提交數(shù)據(jù)的三種方法腳本之家補(bǔ)充
這篇文章主要介紹了asp實(shí)現(xiàn)防止從外部提交數(shù)據(jù)的三種方法,需要的朋友可以參考下2007-11-11asp 數(shù)組 重復(fù)刪除函數(shù)(腳本之家增強(qiáng)版)
這篇文章是asp下刪除重復(fù)數(shù)組的函數(shù),已經(jīng)經(jīng)過測試。2010-05-05ASP向Excel導(dǎo)數(shù)據(jù)(圖片)終結(jié)版 ASP操作Excel
ASP向Excel導(dǎo)數(shù)據(jù)(圖片)終結(jié)版 ASP操作Excel,需要的朋友可以參考下。2009-11-11JScript中遍歷Request表單參數(shù)集合的方法
這篇文章主要介紹了JScript中遍歷Request表單參數(shù)集合的方法,本文以遍歷Request.QueryString集合為例給出了實(shí)現(xiàn)代碼,需要的朋友可以參考下2015-03-03