ASP under the use of FSO to achieve folder or file mobile name and other operating functions _ application Skills
Source: Internet
Author: User
ASP using FSO to achieve file movement
function Movefiles (Sfolder,dfolder)
On Error Resume Next
Dim fso
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
If Fso.folderexists (Server.MapPath (Sfolder)) and Fso.folderexists (Server.MapPath (dfolder)) Then
Fso.copyfolder Server.MapPath (Sfolder), Server.MapPath (Dfolder)
Movefiles = True
Else
Movefiles = False
Set fso = Nothing
Call Alertbox ("The system did not find the specified path [" & Sfolder & "]!", 2)
End If
Set fso = Nothing
End Function
ASP Modify folder name
function Renamefolder (Sfolder,dfolder)
On Error Resume Next
Dim fso
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
If Fso.folderexists (Server.MapPath (sfolder)) Then
Fso.movefolder Server.MapPath (Sfolder), Server.MapPath (Dfolder)
Renamefolder = True
Else
Renamefolder = False
Set fso = Nothing
Call Alertbox ("The system did not find the specified path [" & Sfolder & "]!", 2)
End If
Set fso = Nothing
End Function
ASP checks whether a folder exists
function Checkfolder (spath)
On Error Resume Next
Dim fso
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
If Fso.folderexists (Server.MapPath (spath)) Then
Checkfolder = True
Else
Checkfolder = False
End If
Set fso = Nothing
End Function
ASP Check if file exists
function Checkfile (spath)
On Error Resume Next
Dim fso
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
If Fso.fileexists (Server.MapPath (spath)) Then
Checkfile = True
Else
Checkfile = False
End If
Set fso = Nothing
End Function
ASP Create folder
function Createdir (spath)
Dim Fso,patharr,i,path_level,pathtmp,cpath
On Error Resume Next
spath = replace (spath, "\", "/")
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
Patharr = Split (spath, "/")
Path_level = UBound (Patharr)
For i = 0 to Path_level
If i = 0 then pathtmp = Patharr (0) & "/" Else pathtmp = Pathtmp&patharr (i) & "/"
CPath = Left (Pathtmp,len (pathtmp)-1)
If not fso.folderexists (CPath) then Fso.createfolder (CPath)
Next
Set fso = Nothing
If Err.Number <> 0 Then
Err.Clear
Createdir = False
Else
Createdir = True
End If
End Function
Delete folder, this is the folder to delete the columns in the system
function Delclassfolder (spath)
On Error Resume Next
Dim fso
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
If Fso.folderexists (Server.MapPath (spath)) Then
Fso.deletefolder (Server.MapPath (spath))
End If
Set fso = Nothing
End Function
Delete a news content file
function Delnewsfile (spath,filename)
On Error Resume Next
Dim Fso,temparr,cpath,epath,i:i = 0
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
spath = spath & filename & site_extname
If Fso.fileexists (Server.MapPath (spath)) Then
Fso.deletefile (Server.MapPath (spath))
while (I <>-1)
i = i + 1
Epath = replace (Spath,filename & ".", FileName & "_" & I + 1 & ".")
If Fso.fileexists (Server.MapPath (epath)) Then
Fso.deletefile (Server.MapPath (Epath))
Else
i =-1
End If
Wend
End If
End Function
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.