ASP create files and folders

Source: Internet
Author: User


'==============================
' Function name: CreateFolder
' Function: Create a folder
' Parameter: Folder relative path FolderPath
'==============================
Function CreateFolder (FolderPath)
' On Error Resume Next
Set fso=server.createobject ("Scri" & "Pting"). File "& Sys" & "Temobject")
Set F=fso.createfolder (Server.MapPath (FolderPath))
Createfolder=f.path
Set f=nothing
Set fso=nothing
' Select case ERR
' Case 424 Response.Write (' Side card error tip: When creating the &FolderPath& folder, the path is not found or the directory does not have write permission! ")
' End Select
End Function

'==============================
' Function name: CreateFile
' Function: Create a file
' Parameters: File relative path filepath, file content filecontent
'==============================
Function CreateFile (filepath,filecontent)
' On Error Resume Next
Dim Temps
Temps= ""
Temparr=split (FilePath, "/")
For i=0 to UBound (Temparr)-1
If temps= "" Then
Temps=temparr (i)
Else
temps=temps& "/" &temparr (i)
End If
If Isfolder (Temps) =false Then
Call CreateFolder (Temps)
End If
Next
Set Objadostream = Server.CreateObject ("A" & "DoD" & "B.st" & "R" & "Eam")
Objadostream.type = 2
Objadostream.charset = "UTF-8"
Objadostream.open
Objadostream.writetext = Filecontent
Objadostream.savetofile Server.MapPath (FilePath), 2
Objadostream.close ()
Set Objadostream = Nothing
' Select case ERR
' Case 424 Response.Write ("Side card Error Tip: When creating a &FilePath& file, the path is not found or the directory does not have write permission!" ")
' End Select
End Function

Related Article

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.