使用函數(shù)自動(dòng)生成n層目錄
更新時(shí)間:2006年10月28日 00:00:00 作者:
先檢查是否已經(jīng)存在該目錄了,如果存在,則不做任何處理,如果不存在則創(chuàng)建。
希望對(duì)各位快速開發(fā)有用。
CheckFolder.asp
<%
'***********************************************************************************************************
'作 者: 趙敏 flash90@sohu.com
'頁(yè)面名稱: CreateFolder.asp
'頁(yè)面功能: 生成n層目錄的文件夾
'使用方法: 調(diào)用CheckFolder()函數(shù),例如: CheckFolder(path)
'傳入?yún)?shù): 即將上傳的文件的相對(duì)路徑,例如: path = "./upload/bbb/ccc/ddd"
'缺 點(diǎn): 必須在參數(shù)path里面帶上upload文件夾
'***********************************************************************************************************
Sub CheckFolder(path)
SplitPath(path)
End Sub
Sub SplitPath(path)
dim Road '物理路徑
Road = Server.Mappath("./upload")
dim CurRoad '當(dāng)前路徑
Road = Split(Road,"\",-1,1)
CurRoad = Road(UBound(Road))
dim folder,FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
folder = Split(path,"\",-1,1)
for i = 0 to UBound(folder) step 1
if folder(i) = CurRoad then
j = i
exit for
end if
Next
i = j + 1
if i <= UBound(folder) then
dim myroad
myroad = Server.MapPath(".\upload")
for i = j + 1 to UBound(folder) step 1
CreateFolder myroad,folder(i)
myroad = myroad &"/"& folder(i)
Next
end if
End Sub
Sub CreateFolder(mypath,folderName)
Dim fso,f
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if Not(fso.FolderExists(mypath+"/"+folderName)) then
set f = fso.CreateFolder(mypath+"/"+folderName)
end if
End Sub
Set fso = nothing
%>
希望對(duì)各位快速開發(fā)有用。
CheckFolder.asp
<%
'***********************************************************************************************************
'作 者: 趙敏 flash90@sohu.com
'頁(yè)面名稱: CreateFolder.asp
'頁(yè)面功能: 生成n層目錄的文件夾
'使用方法: 調(diào)用CheckFolder()函數(shù),例如: CheckFolder(path)
'傳入?yún)?shù): 即將上傳的文件的相對(duì)路徑,例如: path = "./upload/bbb/ccc/ddd"
'缺 點(diǎn): 必須在參數(shù)path里面帶上upload文件夾
'***********************************************************************************************************
Sub CheckFolder(path)
SplitPath(path)
End Sub
Sub SplitPath(path)
dim Road '物理路徑
Road = Server.Mappath("./upload")
dim CurRoad '當(dāng)前路徑
Road = Split(Road,"\",-1,1)
CurRoad = Road(UBound(Road))
dim folder,FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
folder = Split(path,"\",-1,1)
for i = 0 to UBound(folder) step 1
if folder(i) = CurRoad then
j = i
exit for
end if
Next
i = j + 1
if i <= UBound(folder) then
dim myroad
myroad = Server.MapPath(".\upload")
for i = j + 1 to UBound(folder) step 1
CreateFolder myroad,folder(i)
myroad = myroad &"/"& folder(i)
Next
end if
End Sub
Sub CreateFolder(mypath,folderName)
Dim fso,f
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if Not(fso.FolderExists(mypath+"/"+folderName)) then
set f = fso.CreateFolder(mypath+"/"+folderName)
end if
End Sub
Set fso = nothing
%>
相關(guān)文章
用XML+FSO+JS實(shí)現(xiàn)服務(wù)器端文件的
用XML+FSO+JS實(shí)現(xiàn)服務(wù)器端文件的...2006-10-10
從文本文件中讀取信息并存儲(chǔ)入數(shù)據(jù)庫(kù)
從文本文件中讀取信息并存儲(chǔ)入數(shù)據(jù)庫(kù)...2006-10-10
ASP中FSO對(duì)象對(duì)IIS WEB服務(wù)器數(shù)據(jù)安全的威脅及對(duì)策
ASP中FSO對(duì)象對(duì)IIS WEB服務(wù)器數(shù)據(jù)安全的威脅及對(duì)策...2006-10-10

