FSO file (File) object properties
DateCreated Returns the date and time of creation of this folder
DateLastAccessed Returns the date and time of the last access to the file
DateLastModified Returns the date and time when the file was last modified
Drive Returns the Drive object of the drive where the file resides
Name Set or return the name of the file
ParentFolder Returns the Folder object of the parent folder of the file
Path Returns the absolute path to the file, and can use a long file name
ShortName Returns the file name in DOS style form 8.3
ShortPath returns the absolute path of the file in DOS style 8.3 form
Size Returns the size (bytes) of the file
Type If possible, return a description string for file type
FSO file (File) object method
Use of FSO file object method
CopyFile Copy one or more files to a new path
CreateTextFile Creates a file and returns a TextStream object
DeleteFile Delete a file
OpenTextFile Opens the file and returns the TextStream object for reading or appending
Rename the file:
The code copy is as follows:
Function reName(sourceName,destName)
dim oFso,oFile
set oFso=server.createobject("Scripting.FileSystemObject")
set oFile=oFso.getFile(Server.mappath(sourceName))
oFile.Name=destName
Set oFso=Nothing
Set oFile=Nothing
End Function
Delete the file:
The code copy is as follows:
Function FSOdel(fileName)
dim fso,f
set fso = server.CreateObject("scripting.filesystemobject")
f=server.MapPath(fileName)
if fso.FileExists(f) then
fso.DeleteFile f,true
end if
set f = nothing
set fso = nothing
End Function
Replace strings in the file:
The code copy is as follows:
Function FSOreplace(fileName,Target,repString)
Dim objFSO,objCountFile,FiletempData
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(fileName),1,True)
FiletempData = objCountFile.ReadAll
objCountFile.Close
FiletempData=Replace(FiletempData,Target,repString)
Set objCountFile=objFSO.CreateTextFile(Server.MapPath(fileName),True)
objCountFile.Write FiletempData
objCountFile.Close
Set objCountFile=Nothing
Set objFSO = Nothing
End Function
<%
'************************************************************
'Function name: CreateFolder(sPath)
'Function: Create a directory
'Path: sPath: The relative directory path created
'Return value: successful true, failed false
'************************************************************
'response.Write createfolder("/dgsunshine/UploadFile/demo1/")
Function CreateFolder(sPath)
On Error Resume Next
Dim Fso, Arrfolder, Folder, i, j
If sPath="" then
CreateFolder = False
Exit Function
End If
If Left(sPath,1) = "/" Then
Folder = "/"
sPath = Mid(sPath,2,Len(sPath))
Else
Folder = "./"
End If
if Right(sPath,1) = "/" then sPath = Left(sPath,Len(sPath)-1)
ArrFolder = Split(sPath,"/")
Set Fso = Server.CreateObject("Scripting.FileSystemObject")