How the ASP detects if a directory exists, does not exist, and creates it itself

Source: Internet
Author: User

How the ASP detects if a directory exists, does not exist, and creates it itself

Folder=server.mappath ("/imagess")
Set fso = CreateObject ("Scripting.FileSystemObject")
If Fso.fileexists (Server.MapPath (filepath)) then
Respnse.write ("Everything is Built")
Else
Fso.createfolder (folder)
End If
Set FSO = Nothing

Dim objFSO
Set objFSO = Server.CreateObject ("Scripting.FileSystemObject")
If objfso.folderexists (Server.MapPath (savepath)) =false Then
Objfso.createfolder (Server.MapPath (Savepath))
End If

Folder=server.mappath ("/imagess")
Set fso = CreateObject ("Scripting.FileSystemObject")
If Fso.fileexists (Server.MapPath (filepath)) then
Respnse.write ("Everything is Built")
Else
Fso.createfolder (folder)
End If
Set FSO = Nothing


' Create a new directory (agree to create without levels) 1:35 2005-1-31 
Public Function CreateFolder (folderpath)  
Dim sobjfso 
Dim arrfolder 
Dim i 

Set sobjfso = Server.CreateObject (" Scripting.FileSystemObject ")  
FolderPath = Replace (FolderPath," \ ","/")  
Arrfolder = Split ( FolderPath, "/")  
on Error Resume next 

For i = 0 to UBound (arrfolder)  
If i > 0 then arrfol Der (i) = Arrfolder (i-1) & "/" & Arrfolder (i)  
If not sobjfso.folderexists (Arrfolder (i)) then 
Sobjfso.createfolder (Arrfolder (i))  
End if 
next 
CreateFolder = true 

If Err.Number <> 0 then 
CreateFolder = false 
err.clear 
End if 
End Function    

Create a Directory

Dim Fso,savepath
Savepath=server. MapPath (". \" &imagefile& "\" &username& "\" &specialname& "")
Set fso = server. CreateObject ("Scripting.FileSystemObject")
If FSO. FolderExists (Savepath) =false Then
Fso.createfolder (Savepath)
End If
Set fso=nothing

Delete Directory

Dim Fso,savepath
Savepath=server. MapPath (". \" &imagefile& "\" &username& "\" &specialname& "")
Set fso = server. CreateObject ("Scripting.FileSystemObject")
If FSO. FolderExists (Savepath) =true Then
Fso.deletefolder (Savepath)
End If
Set fso=nothing

Copy files

Dim fso
Set Fso=server. CreateObject ("Scripting.FileSystemObject")

Sub CopyFiles (PATH,PATH2)
Set Mycopy=fso.getfile (PATH)
Response.Flush ()
Mycopy.copy path2
Response.Write ("<b>installed success!&nbsp;&nbsp;</b>" &path2& "<br>")
Response. Flush ()
End Sub
Call CopyFiles (Server.MapPath (". /Untitled 2.bmp ")," D:\ site project \photo\aspupload\07_images\ ")

How the ASP detects if a directory exists, does not exist, and creates it itself

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.