Recently, I have been attacking Asp.net and have no time to write things. Some FSO functions in ASP have been sorted out and my application is outdated.
'// ====================================================== File operation = ======================================
'File size
Function getfilesize (filename)
'// Function: get the file size
'// Parameter: File Name
'// Return value: The success value is the file size, and the Failure value is-1.
'//
Dim F
If reportfilestatus (filename) = 1 then
Set F = FSO. GetFile (filename)
Getfilesize = f. Size
Else
Getfilesize =-1
End if
End Function
'File Deletion
Function deleteafile (filespec)
'// Function: delete a file
'// Parameter: File Name
'// Return value: Success is 1, failure is-1
'//
If reportfilestatus (filespec) = 1 then
FSO. deletefile (filespec)
Deleteafile = 1
Else
Deleteafile =-1
End if
End Function
'Display the file list
Function showfilelist (folderspec)
'// Function: If a directory exists, all files in the directory are displayed.
'// Parameter: Directory Name
'// Return value: success is the file list, and failure is-1
'//
Dim F, F1, FC, S
If reportfolderstatus (folderspec) = 1 then
Set F = FSO. getfolder (folderspec)
Set fc = f. Files
For each F1 in FC
S = S & f1.name
S = S & "|"
Next
Showfilelist = s
Else
Showfilelist =-1
End if
End Function
'!!!
'File Replication
Function copyafile (sourcefile, destinationfile)
'// Function: only when the source file exists can the file be copied. The target file is not affected.
'// Parameter: source file, target file
'// Return value: Success is 1, failure is-1
'//
Dim myfile
If reportfilestatus (sourcefile) = 1 then
Set myfile = FSO. GetFile (sourcefile)
Myfile. Copy (destinationfile)
Copyafile = 1
Else
Copyafile =-1
End if
End Function
'File Movement
'Response. Write moveafile ("F: \ 123 \ 4561.exe"," F: \ 123 \ 4562.txt ")
Function moveafile (sourcefile, destinationfile)
'// Function: the object can be moved only when the target object does not exist when the source object exists.
'// Parameter: source file, target file
'// Return value: Success is 1, failure is-1
'//
If reportfilestatus (sourcefile) = 1 and reportfilestatus (destinationfileorpath) =
-1 then
FSO. movefile sourcefile, destinationfileorpath
Moveafile = 1
Else
Moveafile =-1
End if
End Function
'Does the file exist?
'Response. Write reportfilestatus ("G: \ soft \ Delphi \ my_pro \ code library .exe ")
Function reportfilestatus (filename)
'// Function: determines whether a file exists
'// Parameter: File Name
'// Return value: Success is 1, failure is-1
'//
Dim msg
MSG =-1
If (FSO. fileexists (filename) then
MSG = 1
Else
MSG =-1
End if
Reportfilestatus = msg
End Function
'File creation date
'Response. Write showdatecreated ("G: \ soft \ Delphi \ my_pro \ code library .exe ")
'Response. Write showdatecreated ("G: \ soft \ Delphi \ my_pro \ Copy code library .exe ")
Function showdatecreated (filespec)
'// Function: file creation date
'// Parameter: File Name
'// Return value: Successful: file creation date, failed:-1
'//
Dim F
If reportfilestatus (filespec) = 1 then
Set F = FSO. GetFile (filespec)
Showdatecreated = f. datecreated
Else
Showdatecreated =-1
End if
End Function
'File attributes
'Response. Write getattributes ("G: \ soft \ Delphi \ my_pro \ Copy code library .exe ")
Function getattributes (filename)
'// Function: display file attributes
'// Parameter: File Name
'// Return value: Success: file property, failed:-1
'//
Dim F, STR
If reportfilestatus (filename) = 1 then
Set F = FSO. GetFile (filename)
Select case F. Attributes
Case 0 STR = "normal file. No attribute is set. "
Case 1 StR = "read-only file. Read/write. "
Case 2 StR = "hide a file. Read/write. "
Case 4 STR = "system file. Read/write. "
Case 16 STR = "folder or directory. Read-only. "
Case 32 STR = "files changed after the last backup. Read/write. "
Case 1024 STR = "link or shortcut. Read-only. "
Case 2048 STR = "compressed file. Read-only. "
End select
Getattributes = Str
Else
Getattributes =-1
End if
End Function
'Last access/last modification time
'Response. Write showfileaccessinfo ("G: \ soft \ Delphi \ my_pro \ Copy code library .exe ")
Function showfileaccessinfo (filename, infotype)
'// Function: displays the file creation information.
'// Parameter: file name, information type
'// 1 ----- Creation Time
'// 2 ----- last access time
'// 3 ----- last modification time
'// 4 ----- file path
'// 5 ----- file name
'// 6 ----- file type
'// 7 ----- File Size
'// 8 ----- parent directory
'// 9 ----- root directory
'// Return value: information when the file is successfully created; failed:-1
'//
Dim F, S
If reportfilestatus (filename) = 1 then
Set F = FSO. GetFile (filename)
Select case infotype
Case 1 S = f. datecreated '// 1 -----
Creation Time
Case 2 S = f. datelastaccessed '// 2 ----- last access
Time
Case 3 S = f. datelastmodified '// 3 ----- last modification
Time
Case 4 S = f. path' // 4
----- File path
Case 5 S = f. name' // 5
----- File name
Case 6 S = f. Type '// 6
----- File type
Case 7 S = f. Size '// 7
----- File Size
Case 8 S = f. parentfolder '// 8 -----
Parent directory
Case 9 S = f. rootfolder '// 8 -----
Root directory
End select
Showfileaccessinfo = s
Else
Showfileaccessinfo =-1
End if
End Function
'Write a text file
Function writetxtfile (filename, textstr, writeorappendtype)
Const forreading = 1, forwriting = 2, forappending = 8
Dim F, m
Select case writeorappendtype
Case 1: 'file write operations
Set F = FSO. opentextfile (filename, forwriting, true)
F. Write textstr
F. Close
If reportfilestatus (filename) = 1 then
Writetxtfile = 1
Else
Writetxtfile =-1
End if
Case 2: 'write at the end of the file
If reportfilestatus (filename) = 1 then
Set F = FSO. opentextfile (filename, forappending)
F. Write textstr
F. Close
Writetxtfile = 1
Else
Writetxtfile =-1
End if
End select
End Function
'Read text files
Function readtxtfile (filename)
Const forreading = 1, forwriting = 2
Dim F, m
If reportfilestatus (filename) = 1 then
Set F = FSO. opentextfile (filename, forreading)
M = f. Readline
'M = f. readall
'F. skipline
Readtxtfile = m
F. Close
Else
Readtxtfile =-1
End if
End Function
'Create a text file
'// ====================================================== Directory operation = ======================================
'Get directory size
Function getfoldersize (Foldername)
'// Function: Get the directory size
'// Parameter: Directory Name
'// Return value: the directory size for success and-1 for failure
'//
Dim F
If reportfolderstatus (Foldername) = 1 then
Set F = FSO. getfolder (Foldername)
Getfoldersize = f. Size
Else
Getfoldersize =-1
End if
End Function
'Created folder
Function createfolderdemo (Foldername)
'// Function: the created folder
'// Parameter: Directory Name
'// Return value: Success is 1, failure is-1
'//
Dim F
If reportfolderstatus (folderspec) = 1 then
Createfolderdemo =-1
Else
Set F = FSO. createfolder (Foldername)
Createfolderdemo = 1
End if
End Function
'!!!
'Directory Deletion
Function deleteafolder (folderspec)
'// Function: delete a directory
'// Parameter: Directory Name
'// Return value: Success is 1, failure is-1
'//
Response. Write folderspec
If reportfolderstatus (folderspec) = 1 then
FSO. deletefolder (folderspec)
Deleteafolder = 1
Else
Deleteafolder =-1
End if
End Function
'Display the Directory List
Function showfolderlist (folderspec)
'// Function: When a directory exists, all subdirectories under the directory are displayed.
'// Parameter: Directory Name
'// Return value: the success is the subdirectory list, and the failure is-1
'//
Dim F, F1, FC, S
If reportfolderstatus (folderspec) = 1 then
Set F = FSO. getfolder (folderspec)
Set fc = f. subfolders
For each F1 in FC
S = S & f1.name
S = S & "|"
Next
Showfolderlist = s
Else
Showfolderlist =-1
End if
End Function
'!!!!
'Directory Replication
Function copyafolder (sourcefolder, destinationfolder)
'// Function: if the source directory exists, the directory can be copied without affecting the target directory.
'// Parameter: Source directory, target directory
'// Return value: Success is 1, failure is-1
'//
'Dim myfolder
'If reportfolderstatus (sourcefolder) = 1 and reportfolderstatus
(Destinationfolder) =-1 then
'Set myfolder = FSO. getfolder (sourcefolder)
FSO. copyfolder sourcefolder, destinationfolder
Copyafolder = 1
'Else
Copyafolder =-1
'End if
End Function
'Directory to move
Function moveafolder (sourcepath, destinationpath)
'// Function: the directory can be moved only when the target directory does not exist when the source directory exists.
'// Parameter: Source directory, target directory
'// Return value: Success is 1, failure is-1
'//
If reportfolderstatus (sourcepath) = 1 and reportfolderstatus (destinationpath) = 0
Then
FSO. movefolder sourcepath, destinationpath
Moveafolder = 1
Else
Moveafolder =-1
End if
End Function
'Determine whether the directory exists
'Response. Write reportfolderstatus ("G: \ soft \ Delphi \ my_pro \")
Function reportfolderstatus (FLDR)
'// Function: determines whether a directory exists
'// Parameter: Directory
'// Return value: Success is 1, failure is-1
'//
Dim msg
MSG =-1
If (FSO. folderexists (FLDR) then
MSG = 1
Else
MSG =-1
End if
Reportfolderstatus = msg
End Function
'Directory creation Information
Function showfolderaccessinfo (Foldername, infotype)
'// Function: displays the Directory Creation information.
'// Parameter: directory name, information type
'// 1 ----- Creation Time
'// 2 ----- last access time
'// 3 ----- last modification time
'// 4 ----- directory path
'// 5 ----- directory name
'// 6 ----- directory type
'// 7 ----- directory size
'// 8 ----- parent directory
'// 9 ----- root directory
'// Return value: information when the directory is successfully created, failed:-1
'//
Dim F, S
If reportfolderstatus (Foldername) = 1 then
Set F = FSO. getfolder (Foldername)
Select case infotype
Case 1 S = f. datecreated '// 1 -----
Creation Time
Case 2 S = f. datelastaccessed '// 2 ----- last access
Time
Case 3 S = f. datelastmodified '// 3 ----- last modification
Time
Case 4 S = f. path' // 4
----- File path
Case 5 S = f. name' // 5
----- File name
Case 6 S = f. Type '// 6
----- File type
Case 7 S = f. Size '// 7
----- File Size
Case 8 S = f. parentfolder '// 8 -----
Parent directory
Case 9 S = f. rootfolder '// 9 -----
Root directory
End select
Showfolderaccessinfo = s
Else
Showfolderaccessinfo =-1
End if
End Function
Function displayleveldepth (pathspec)
Dim F, N, path
Set F = FSO. getfolder (pathspec)
If F. isrootfolder then
Displayleveldepth = "the specified folder is the root folder. "& Rootfolder
Else
Do until F. isrootfolder
Path = Path & F. Name & "<br>"
Set F = f. parentfolder
N = n + 1
Loop
Displayleveldepth = "the specified folder is a folder with a nesting level of" & N. <Br> "&
Path
End if
End Function
'// ======================================== Disk operation = ======================================
'Does the drive exist?
'Response. Write reportdrivestatus ("C :\")
Function reportdrivestatus (DRV)
'// Function: determines whether a disk exists
'// Parameter: Disk
'// Return value: Success is 1, failure is-1
'//
Dim msg
MSG =-1
If FSO. driveexists (DRV) then
MSG = 1
Else
MSG =-1
End if
Reportdrivestatus = msg
End Function
'-------- Available return types include fat, NTFS, and CDFs.
'Response. Write showfilesystemtype ("C :\")
Function showfilesystemtype (drvspec)
'// Function: Disk Type
'// Parameter: disk name
'// Return value: Success type: fat, NTFS, and CDFs; Failure:-1
'//
Dim d
If reportdrivestatus (drvspec) = 1 then
Set d = FSO. getdrive (drvspec)
Showfilesystemtype = D. filesystem
Else
Showfilesystemtype =-1
End if
End Function
End Class
%>