Documents, catalog, text files, etc.

xiaoxiao2021-03-05  24

Relaxlife.net boutique code ASP SQL file, directory, text file, etc., etc. / ***************************************** *******************

*

* Documents, catalog, text files, etc.

*

* You can't put all the code here, more please

Www.relaxlife.net

* Come on! !

*

********************************************************* /

<%

DIM MyFileFolder

Set myfilefolder = new filefoldercls

'Response.write myfilefolder.moveafile ("f: /123/4561.exe", "f: /123/4562.txt")

'Response.write myfilefolder.moveafolder ("f: / 456", "f: / decg / 456")

'Response.write myfilefolder.showFilesystemType ("i: /")

'Response.write myfilefolder.copyafile ("f: /123/4562.txt", "f: /123/4563.txt")

'!!!!

'Response.write myfilefolder.copyafolder ("f: / 123 /", "f: / 789 /")

'Response.write myfilefolder.showfolderlist ("f: / dec")

'Response.write myfilefolder.showFileList ("f: / 123/123")

'Response.write myfilefolder.deleteafile ("f: /123/4562.txt")

'Response.write myfilefolder.deleteafolder ("f: / 456 /")

'Response.write myfilefolder.createfolderdemo ("f: / 147 /")

'Response.write myfilefolder.getfilesize ("f: /123/4563.txt")

'Response.write myfilefolder.getfoldersize ("f: /123/123.txt")

'Response.write myfilefolder.showfileaccessinfo ("f: /123/123.txt", 1) & "
"

'Response.write myfilefolder.showfileAccessinfo ("f: /123/123.txt", 2) & "
"

'Response.write myfilefolder.showfileAccessinfo ("f: /123/123.txt", 3) & "
"

'Response.write myfilefolder.showfileAccessinfo ("f: /123/123.txt", 4) & "
"

'Response.write myfilefolder.showfileAccessinfo ("F: /123/123.txt", 5) & "
"' response.write myfilefolder.showfileAccessinfo ("f: /123/123.txt", 6) & "

'Response.write myfilefolder.showfileAccessinfo ("f: /123/123.txt", 7) & "
"

'Response.write myfilefolder.showfileAccessinfo ("f: /123/123.txt", 8) & "
"

'Response.write myfilefolder.showfoldesergeseinfo ("f: / 123 /", 1) & "
"

'Response.write myfilefolder.showfoldesergergergesergessinfo ("F: / 123 /", 2) & "
"

'Response.write myfilefolder.showfolderaccessinfo ("f: / 123 /", 3) & "
"

'Response.write myfilefolder.showfoldesergergergerge ("f: / 123 /", 4) & "
"

'Response.write myfilefolder.showfoldesergeseinfo ("F: / 123 /", 5) & "
"

'Response.write myfilefolder.showfoldesergeseinfo ("f: / 123 /", 6) & "
"

'Response.write myfilefolder.showfoldesergeseinfo ("F: / 123 /", 7) & "
"

'Response.write myfilefolder.showfoldesergeseinfo ("f: / 123 /", 8) & "
"

'Response.write myfilefolder.writetxtfile ("f: /123/Cexo.txt", ", 1) &"
"

'Response.write myfilefolder.writetxtfile ("f: /123/Cexo.txt", "Cexowxfdw", 1) & "
"

'Response.write myfilefolder.writetxtfile ("f: /123/Cexo.txt", chr (13) & chr (10)

& "Cexowxfdw", 2) & "
"

'Response.write myfilefolder.readtxtfile ("f: /123/Cexo.txt") & "
"

Response.write myfilefolder.displayLevelDepth ("f: / decg / ditg / bumen / images") & "
" Class FileFolderCls

Public FSO

Private sub coplass_initialize ()

SET FSO = CreateObject ("scripting.filesystemObject")

End Sub

Private sub coplass_terminate ()

SET FSO = Nothing

End Sub

'// ========================================================================================================================================================================================================================== =====================================================================================================================================================

'Take a file size

Function GetFileSize (filename)

'// function: Take the size of the file

'// Participation: File Name

'// Return value: success is the file size, failure 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: file deletion

'// Participation: 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 file list

Function ShowFileList (Folderspec)

'// Function: Display all files in this directory when the directory exists

'// Conversion: Directory Name

'// Return value: success is a list of files, failed to -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: When the source file exists, the file can be copied, and the purpose of the purpose file has no effect' // denim: source file, destination 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 file can be moved when the destination file does not exist when there is a source file.

'// meticulous: source file, destination 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 / CS. EXE")

Function ReportFileStatus (filename)

'// function: Judging whether the file exists

'// Participation: File Name

'// Return value: success is 1, failure is -1

'//

DIM MSG

MSG = -1

IF (fso.fileexists (filename))

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: Date of file creation

'// Participation: File Name

'// Return Value: Success: File Create Date, Failure: -1

'//

DIM F

IF reportFileStatus (filespec) = 1 THEN

Set f = fso.getfile (filespec)

Showdatecreated = f.datecreated

Else

Showdatecreated = -1

END IF

END FUNCTION

'File properties

'Response.write GetAttributes ("G: / Soft / Delphi / MY_PRO / Removal Code Base") Function GetAttributes (FileName)

'// function: Display file properties

'// Participation: File Name

'// Return Value: Success: File Attribute, Failure: -1

'//

DIM F, STR

If ReportFileStatus (filename) = 1 THEN

Set f = fso.getfile (filename)

Select Case F.Attributes

Case 0 str = "normal file. No properties are set."

Case 1 str = "read-only file. Ready to write."

Case 2 str = "hides files. Ready to write."

Case 4 str = "system file. Ready to write."

Case 16 str = "folder or directory. Read only."

Case 32 str = "The file has been changed after the last backup. Ready to write."

Case 1024 str = "Link or shortcut. Read only."

Case 2048 str = "Compressed files. Read only."

End SELECT

GetaTtributes = STR

Else

GetaTtributes = -1

END IF

END FUNCTION

'Last visited / last modification time

'Response.write showfileAccessinfo ("G: / Soft / Delphi / MY_PRO / Removal Code Base. EXE")

Function ShowFileAccessinfo (FileName, Infotype)

'// function: Display file creation time information

'// Participation: file name, information category

'// 1 ----- creation time

'// 2 ----- last visited time

'// 3 ----- last revised time

'// 4 ----- File path

'// 5 ----- File Name

'// 6 ----- File type

'// 7 ----- File size

'// 8 ----- parent catalog

'// 9 ----- root directory

'// Return value: successfully created information for files, failed: -1

'//

DIM F, S

If ReportFileStatus (filename) = 1 THEN

Set f = fso.getfile (filename)

SELECT CASE INFOTYPE

Case 1 s = f.datecreated '// 1 -----

Create time

Case 2 s = f.dateLastAccessed '// 2 ----- last visited

time

Case 3 s = f.dateLastModified '// 3 ----- last modified

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, WriteraPpendtype)

Const forreading = 1, forWriting = 2, FORAPPPpending = 8

DIM F, M

SELECT CASE WRITEORAPPENDTYPE

Case 1: 'file is written

Set f = fso.opentextfile (filename, forting, true)

F.Write Textstr

f.close

If ReportFileStatus (filename) = 1 THEN

WriteTxtFile = 1

Else

WriteTxtFile = -1

END IF

Case 2: 'The end of the file is written

If ReportFileStatus (filename) = 1 THEN

Set f = fso.opentextfile (filename, forepens)

F.Write Textstr

f.close

WriteTxtFile = 1

Else

WriteTxtFile = -1

END IF

End SELECT

END FUNCTION

'Read the text file

Function ReadTxtFile (filename)

Const forreading = 1, forwriting = 2

DIM F, M

If ReportFileStatus (filename) = 1 THEN

Set f = fso.opentextfile (filename, forereading)

m = f.readline

'm = f.readall

'f.skipline

ReadtxtFile = M

f.close

Else

ReadtxtFile = -1

END IF

END FUNCTION

'Establish text files

'// ================================== Directory operation =========== =====================================================================================================================================================

'Take the directory size

Function getFoldersize (FolderName) '// function: Take the directory size

'// Conversion: Directory Name

'// Return value: success is a directory size, failed to -1

'//

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: created folder

'// Conversion: 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: directory delete

'// Conversion: 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 directory list

Function ShowFolderList (Folderspec)

'// Function: Display all subdirectory in this directory when the directory exists

'// Conversion: Directory Name

'// Return value: successfully for the child directory list, failed to -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 copy

Function CopyAfolder (Sourcefolder, DestinationFolder)

'// function: When the source directory exists, you can copy the directory, and the destination directory has no effect.

'// Guan Shen: Source Catalog, 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

Function Moveafolder (SourcePath, DestinationPath)

'// function: The destination directory does not exist when the source directory does not exist.

'// Guan Shen: Source Catalog, 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 if the directory exists

'Response.write ReportFolderstatus ("g: / Soft / Delphi / my_pro /")

Function ReportFolderstatus (FLDR)

'// Function: Determine if the directory exists

'// Participation: Directory

'// Return value: success is 1, failure is -1

'//

DIM MSG

MSG = -1

IF (fso.folderexiss (fldr)) THEN

MSG = 1

Else

MSG = -1

END IF

ReportFolderstatus = MSG

END FUNCTION

'Directory creation information

Function ShowFolderAccessInfo (Foldername, Infotype)

'// Function: Display Directory Creation Information

'// Conversion: Directory Name, Information Category

'// 1 ----- creation time

'// 2 ----- last visited time

'// 3 ----- last revised time

'// 4 ----- Directory path

'// 5 ----- directory name

'// 6 ----- Directory Type

'// 7 ----- directory size

'// 8 ----- parent catalog

'// 9 ----- root directory

'// Return Value: Successfully created information, failed: -1

'//

DIM F, S

IF reportFoldersTatus (FolderName) = 1 THEN

Set f = fso.getfolder (foldername)

SELECT CASE INFOTYPE

Case 1 s = f.datecreated '// 1 -----

Create time

Case 2 s = f.dateLastAccessed '// 2 ----- last visited

time

Case 3 s = f.dateLastModified '// 3 ----- last modified

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

ShowfoldessInfo = S

Else

Showfoldesenfo = -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 & "
"

Set f = f.parentfolder

n = n 1

Loop

DisplayLevelDepth = "The specified folder is a folder of nested levels" & n & ".
" &

Path

END IF

END FUNCTION

'// ================================== Disk operation ============ =====================================================================================================================================================

Does the driver exist?

'Response.write ReportDriveStatus ("C: /")

Function ReportDriveStatus (DRV)

'// function: Judgment the disk exists

'// Gentrus: 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

'-------- The return type available includes FAT, NTFS, and CDFS.

'Response.write ShowFileSystemType ("C: /")

Function ShowFileSystemType (DRVSPEC) '// Function: Disk Type

'// Ginseng: Disk Name

'// Return Value: Success is 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

%>

[This post was edited by CEXO255 in 2005-4-3 18:33]

转载请注明原文地址:https://www.9cbs.com/read-35990.html

New Post(0)