Tutorials to .com

Tutorials to .com » Asp » Fso » Automatically generated using the function n layer directory

Automatically generated using the function n layer directory

Print View , by: iSee ,Total views: 11 ,Word Count: 317 ,Date: Thu, 16 Apr 2009 Time: 4:55 AM

To check whether the directory already exists, and if there is not any treatment, if it does not exist to create.
I hope to quickly develop useful to you.
CheckFolder.asp

<%
'************************************************* ************************************************** ********
'Author: Zhao flash90@sohu.com
'Page name: CreateFolder.asp
'Page features: generate n layer folder directory
'Usage: call CheckFolder () functions, such as: CheckFolder (path)
'Incoming parameters: the document is about to upload the relative path, for example: path = ". / Upload / bbb / C++ / ddd"
'Disadvantages: path parameter must be brought inside the upload folder
'************************************************* ************************************************** ********
Sub CheckFolder (path)
SplitPath (path)
End Sub
Sub SplitPath (path)
dim Road 'physical path
Road = Server.Mappath ( ". / Upload")
dim CurRoad 'current path
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
%>


ASP File System Object Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.