ASP combined with FSO to achieve file or folder creation delete operations such as function _ Application skills

Source: Internet
Author: User
'////////////////////////////////////////////////fso Operation/////////////////////////////////////
' Determine if a folder exists
Function folderexits (Folder)
Folder=server.mappath (Folder)
Set fso= Server.CreateObject ("Scripting.FileSystemObject")
IF FSO. FolderExists (Folder) Then
Folderexits=true
Else
Folderexits=false
End IF
End Function

' to determine if a file exists
Function fileexits (FileName)
Filename=server.mappath (FileName)
Set fso= Server.CreateObject ("Scripting.FileSystemObject")
IF FSO. FileExists (FileName) Then
Fileexits=true
Else
Fileexits=false
End IF
End Function

' Create a folder
Function CreateFolder (Folder)
On Error Resume Next
Folder=server.mappath (Folder)
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
Fso. CreateFolder (Folder)
If Err>0 Then
Err.Clear
Createfolder=false
Else
Createfolder=true
End If
End Function

' Create a file
Function CreateFile (filename,content)
On Error Resume Next
Filename=server.mappath (FileName)
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
Set Fd=fso.createtextfile (filename,true)
Fd.writeline Content
If Err>0 Then
Err.Clear
Createfile=false
Else
Createfile=true
End If
End Function

' Delete file
function DeleteFile (FileName)
On Error Resume Next
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
If FSO. FileExists (FileName) Then
Fso. DeleteFile Filename,true
End If
If Err>0 Then
Err.Clear
Deletefile=false
Else
Deletefile=true
End If
End Function

' Delete Folder
function DeleteFolder (Folder)
On Error Resume Next
Folder=server. MapPath (Folder)
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
If FSO. FolderExists (Folder) Then
Fso. DeleteFolder folder,true
End If
If Err>0 Then
Err.Clear
Deletefolder=false
Else
Deletefolder=true
End If
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.