« Different between Girls and Matured Women | Main | Ketulusan Hati »

File System Object: Create_Folder

<%
Const wexRoot = "/x/binaries/"
wexRootPath = RealizePath(wexRoot)
Function FixPath(path, slash)
    If Right(path, 1) <> slash Then
           FixPath = path & slash
       Else
        FixPath = path
       End If
End Function

Function RealizePath(path)
    Dim fpath
    fpath = replace(path,"/","\")
    If left(fpath,1) = "\" Then 'Virtual path
        on error resume next
        RealizePath = server.MapPath(fpath)
        If err.Number<>0 Then RealizePath = fpath 'Possibly network path
    Else 'Physical Path
        RealizePath = fpath
    End If
    RealizePath = FixPath(RealizePath, "\")
End Function

Function CreateFolder(itemName)

    itemPath = wexRootPath & itemName

    Set FSO = server.CreateObject ("Scripting.FileSystemObject")

    on error resume next
    Response.Buffer = true

    If FSO.FolderExists(itemPath) = false and FSO.FileExists(itemPath) = false Then
        FSO.CreateFolder(itemPath)
        If err.Number <> 0 Then
            wexMessage = "Unable to create the folder """ & itemName & """, an error occured..."
        Else
            wexMessage = "Created the folder """ & itemName & """..."
        End If
    Else
        wexMessage = "Unable to create the folder """ & itemName & """, there exists a file or a folder with the same name..."
    End If

    Set FSO = nothing
    response.write wexMessage
    response.write "<br>" & itemPath
End Function
%>

Create folder

<%
CreateFolder "My New Folder"
%>

                            

Comments

Post a comment

Post a comment

Name:

You are currently signed in as .


August 2008

Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31