-
asp.net教程之Asp中一些FSO方面的函數
- 2017-06-11 20:13 來源:未知
''//==================================文件操作==================================
''取文件大小
Function GetFileSize(FileName)
''//功能:取文件大小
''//形參:文件名
''//返回值:成功為文件大小,失敗為-1
''//
Dim f
If ReportFileStatus(FileName) = 1 Then
Set f = fso.Getfile(FileName)
GetFileSize = f.Size
Else
GetFileSize = -1
End if
End Function
''文件刪除
Function deleteAFile(filespec)
''//功能:文件刪除
''//形參:文件名
''//返回值:成功為1,失敗為-1
''//
If ReportFileStatus(filespec) = 1 Then
fso.deleteFile(filespec)
deleteAFile = 1
Else
deleteAFile = -1
End if
End Function
''顯示文件列表
Function ShowFileList(folderspec)
''//功能:目錄存在時顯示此目錄下的所有文件
''//形參:目錄名
''//返回值:成功為文件列表,失敗為-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
''!!!
''文件復制
Function CopyAFile(SourceFile,DestinationFile)
''//功能:源文件存在時,才能對文件進行復制,目的文件無影響
''//形參:源文件,目的文件
''//返回值:成功為1,失敗為-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
''文件移動
''Response.Write MoveAFile("f:\123\4561.exe","f:\123\4562.txt")
Function MoveAFile(SourceFile,DestinationFile)
''//功能:源文件存在時目的文件不存在時才能對文件進行移動
''//形參:源文件,目的文件
''//返回值:成功為1,失敗為-1
''//
If ReportFileStatus(SourceFile)=1 And ReportFileStatus(DestinationFileORPath) =
-1 Then
fso.MoveFile SourceFile,DestinationFileORPath
MoveAFile = 1
Else
MoveAFile = -1
End if
End Function
''文件是否存在?
''Response.Write ReportFileStatus("G:\soft\delphi\my_pro\代碼庫.exe")
Function ReportFileStatus(FileName)
''//功能:判斷文件是否存在
''//形參:文件名
''//返回值:成功為1,失敗為-1
''//
Dim msg
msg = -1
If (fso.FileExists(FileName)) Then
msg = 1
Else
msg = -1
End If
ReportFileStatus = msg
End Function
''文件創建日期
''Response.Write ShowDatecreated("G:\soft\delphi\my_pro\代碼庫.exe")
''Response.Write ShowDatecreated("G:\soft\delphi\my_pro\復件 代碼庫.exe")
Function ShowDatecreated(filespec)
''//功能:文件創建日期
''//形參:文件名
''//返回值:成功:文件創建日期,失敗:-1
''//
Dim f
If ReportFileStatus(filespec) = 1 Then
Set f = fso.GetFile(filespec)
ShowDatecreated = f.Datecreated
Else
ShowDatecreated = -1
End if
End Function
''文件屬性
''Response.Write GetAttributes("G:\soft\delphi\my_pro\復件 代碼庫.exe")
Function GetAttributes(FileName)
''//功能:顯示文件屬性
''//形參:文件名
''//返回值:成功:文件屬性,失敗:-1
''//
Dim f,Str
If ReportFileStatus(FileName) = 1 Then
Set f = fso.GetFile(FileName)
select Case f.attributes
Case 0 Str="普通文件。沒有設置任何屬性。 "
Case 1 Str="只讀文件。可讀寫。 "
Case 2 Str="隱藏文件。可讀寫。 "
Case 4 Str="系統文件。可讀寫。 "
Case 16 Str="文件夾或目錄。只讀。 "
Case 32 Str="上次備份后已更改的文件。可讀寫。 "
Case 1024 Str="鏈接或快捷方式。只讀。 "
Case 2048 Str=" 壓縮文件。只讀。"
End select
GetAttributes = Str
Else
GetAttributes = -1
End if
End Function
''最后一次訪問/最后一次修改時間
''Response.Write ShowFileAccessInfo("G:\soft\delphi\my_pro\復件 代碼庫.exe")
Function ShowFileAccessInfo(FileName,InfoType)
''//功能:顯示文件創建時信息
''//形參:文件名,信息類別
''// 1 -----創建時間
''// 2 -----上次訪問時間
''// 3 -----上次修改時間
''// 4 -----文件路徑
''// 5 -----文件名稱
''// 6 -----文件類型
''// 7 -----文件大小
''// 8 -----父目錄
''// 9 -----根目錄
''//返回值:成功為文件創建時信息,失敗:-1
''//
Dim f, s
If ReportFileStatus(FileName) = 1 then
Set f = fso.GetFile(FileName)
select Case InfoType
Case 1 s = f.Datecreated ''// 1 -----
創建時間
Case 2 s = f.DateLastAccessed ''// 2 -----上次訪問
時間
Case 3 s = f.DateLastModified ''// 3 -----上次修改
時間
Case 4 s = f.Path ''// 4
-----文件路徑
Case 5 s = f.Name ''// 5
-----文件名稱
Case 6 s = f.Type ''// 6
-----文件類型
Case 7 s = f.Size ''// 7
-----文件大小
Case 8 s = f.ParentFolder ''// 8 -----
父目錄
Case 9 s = f.RootFolder ''// 8 -----
根目錄
End select
ShowFileAccessInfo = s
ELse
ShowFileAccessInfo = -1
End if
End Function
''寫文本文件
Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
Dim f, m
select Case WriteORAppendType
Case 1: ''文件進行寫操作
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: ''文件末尾進行寫操作
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
''讀文本文件
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
''建立文本文件
''//==================================目錄操作==================================
''取目錄大小
Function GetFolderSize(FolderName)
''//功能:取目錄大小
''//形參:目錄名
''//返回值:成功為目錄大小,失敗為-1
''//
Dim f
If ReportFolderStatus(FolderName) = 1 Then
Set f = fso.GetFolder(FolderName)
GetFolderSize = f.Size
Else
GetFolderSize = -1
End if
End Function
''創建的文件夾
Function createFolderDemo(FolderName)
''//功能:創建的文件夾
''//形參:目錄名
''//返回值:成功為1,失敗為-1
''//
Dim f
If ReportFolderStatus(Folderspec) = 1 Then
createFolderDemo = -1
Else
Set f = fso.createFolder(FolderName)
createFolderDemo = 1
End if
End Function
''!!!
''目錄刪除
Function deleteAFolder(Folderspec)
''//功能:目錄刪除
''//形參:目錄名
''//返回值:成功為1,失敗為-1
''//
Response.write Folderspec
If ReportFolderStatus(Folderspec) = 1 Then
fso.deleteFolder (Folderspec)
deleteAFolder = 1
Else
deleteAFolder = -1
End if
End Function
''顯示目錄列表
Function ShowFolderList(folderspec)
''//功能:目錄存在時顯示此目錄下的所有子目錄
''//形參:目錄名
''//返回值:成功為子目錄列表,失敗為-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
''!!!!
''目錄復制
Function CopyAFolder(SourceFolder,DestinationFolder)
''//功能:源目錄存在時,才能對目錄進行復制,目的目錄無影響
''//形參:源目錄,目的目錄
''//返回值:成功為1,失敗為-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
''目錄進行移動
Function MoveAFolder(SourcePath,DestinationPath)
''//功能:源目錄存在時目的目錄不存在時才能對目錄進行移動
''//形參:源目錄,目的目錄
''//返回值:成功為1,失敗為-1
''//
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0
Then
fso.MoveFolder SourcePath, DestinationPath
MoveAFolder = 1
Else
MoveAFolder = -1
End if
End Function
''判斷目錄是否存在
''Response.Write ReportFolderStatus("G:\soft\delphi\my_pro\")
Function ReportFolderStatus(fldr)
''//功能:判斷目錄是否存在
''//形參:目錄
''//返回值:成功為1,失敗為-1
''//
Dim msg
msg = -1
If (fso.FolderExists(fldr)) Then
msg = 1
Else
msg = -1
End If
ReportFolderStatus = msg
End Function
''目錄創建時信息
Function ShowFolderAccessInfo(FolderName,InfoType)
''//功能:顯示目錄創建時信息
''//形參:目錄名,信息類別
''// 1 -----創建時間
''// 2 -----上次訪問時間
''// 3 -----上次修改時間
''// 4 -----目錄路徑
''// 5 -----目錄名稱
''// 6 -----目錄類型
''// 7 -----目錄大小
''// 8 -----父目錄
''// 9 -----根目錄
''//返回值:成功為目錄創建時信息,失敗:-1
''//
Dim f, s
If ReportFolderStatus(FolderName) = 1 then
Set f = fso.GetFolder(FolderName)
select Case InfoType
Case 1 s = f.Datecreated ''// 1 -----
創建時間
Case 2 s = f.DateLastAccessed ''// 2 -----上次訪問
時間
Case 3 s = f.DateLastModified ''// 3 -----上次修改
時間
Case 4 s = f.Path ''// 4
-----文件路徑
Case 5 s = f.Name ''// 5
-----文件名稱
Case 6 s = f.Type ''// 6
-----文件類型
Case 7 s = f.Size ''// 7
-----文件大小
Case 8 s = f.ParentFolder ''// 8 -----
父目錄
Case 9 s = f.RootFolder ''// 9 -----
根目錄
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 ="指定的文件夾是根文件夾。"&RootFolder
Else
Do Until f.IsRootFolder
Path = Path & f.Name &"<br>"
Set f = f.ParentFolder
n = n + 1
Loop
DisplayLevelDepth ="指定的文件夾是嵌套級為 " & n & " 的文件夾。<br>"&
Path
End If
End Function
''//==================================磁盤操作==================================
''驅動器是否存在?
''Response.Write ReportDriveStatus("C:\")
Function ReportDriveStatus(drv)
''//功能:判斷磁盤是否存在
''//形參:磁盤
''//返回值:成功為1,失敗為-1
''//
Dim msg
msg = -1
If fso.DriveExists(drv) Then
msg = 1
Else
msg = -1
End If
ReportDriveStatus = msg
End Function
''--------可用的返回類型包括 FAT、NTFS 和 CDFS。
''Response.Write ShowFileSystemType("C:\")
Function ShowFileSystemType(drvspec)
''//功能:磁盤類型
''//形參:磁盤名
''//返回值:成功為類型:FAT、NTFS 和 CDFS,失敗:-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
%>
''取文件大小
Function GetFileSize(FileName)
''//功能:取文件大小
''//形參:文件名
''//返回值:成功為文件大小,失敗為-1
''//
Dim f
If ReportFileStatus(FileName) = 1 Then
Set f = fso.Getfile(FileName)
GetFileSize = f.Size
Else
GetFileSize = -1
End if
End Function
''文件刪除
Function deleteAFile(filespec)
''//功能:文件刪除
''//形參:文件名
''//返回值:成功為1,失敗為-1
''//
If ReportFileStatus(filespec) = 1 Then
fso.deleteFile(filespec)
deleteAFile = 1
Else
deleteAFile = -1
End if
End Function
''顯示文件列表
Function ShowFileList(folderspec)
''//功能:目錄存在時顯示此目錄下的所有文件
''//形參:目錄名
''//返回值:成功為文件列表,失敗為-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
''!!!
''文件復制
Function CopyAFile(SourceFile,DestinationFile)
''//功能:源文件存在時,才能對文件進行復制,目的文件無影響
''//形參:源文件,目的文件
''//返回值:成功為1,失敗為-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
''文件移動
''Response.Write MoveAFile("f:\123\4561.exe","f:\123\4562.txt")
Function MoveAFile(SourceFile,DestinationFile)
''//功能:源文件存在時目的文件不存在時才能對文件進行移動
''//形參:源文件,目的文件
''//返回值:成功為1,失敗為-1
''//
If ReportFileStatus(SourceFile)=1 And ReportFileStatus(DestinationFileORPath) =
-1 Then
fso.MoveFile SourceFile,DestinationFileORPath
MoveAFile = 1
Else
MoveAFile = -1
End if
End Function
''文件是否存在?
''Response.Write ReportFileStatus("G:\soft\delphi\my_pro\代碼庫.exe")
Function ReportFileStatus(FileName)
''//功能:判斷文件是否存在
''//形參:文件名
''//返回值:成功為1,失敗為-1
''//
Dim msg
msg = -1
If (fso.FileExists(FileName)) Then
msg = 1
Else
msg = -1
End If
ReportFileStatus = msg
End Function
''文件創建日期
''Response.Write ShowDatecreated("G:\soft\delphi\my_pro\代碼庫.exe")
''Response.Write ShowDatecreated("G:\soft\delphi\my_pro\復件 代碼庫.exe")
Function ShowDatecreated(filespec)
''//功能:文件創建日期
''//形參:文件名
''//返回值:成功:文件創建日期,失敗:-1
''//
Dim f
If ReportFileStatus(filespec) = 1 Then
Set f = fso.GetFile(filespec)
ShowDatecreated = f.Datecreated
Else
ShowDatecreated = -1
End if
End Function
''文件屬性
''Response.Write GetAttributes("G:\soft\delphi\my_pro\復件 代碼庫.exe")
Function GetAttributes(FileName)
''//功能:顯示文件屬性
''//形參:文件名
''//返回值:成功:文件屬性,失敗:-1
''//
Dim f,Str
If ReportFileStatus(FileName) = 1 Then
Set f = fso.GetFile(FileName)
select Case f.attributes
Case 0 Str="普通文件。沒有設置任何屬性。 "
Case 1 Str="只讀文件。可讀寫。 "
Case 2 Str="隱藏文件。可讀寫。 "
Case 4 Str="系統文件。可讀寫。 "
Case 16 Str="文件夾或目錄。只讀。 "
Case 32 Str="上次備份后已更改的文件。可讀寫。 "
Case 1024 Str="鏈接或快捷方式。只讀。 "
Case 2048 Str=" 壓縮文件。只讀。"
End select
GetAttributes = Str
Else
GetAttributes = -1
End if
End Function
''最后一次訪問/最后一次修改時間
''Response.Write ShowFileAccessInfo("G:\soft\delphi\my_pro\復件 代碼庫.exe")
Function ShowFileAccessInfo(FileName,InfoType)
''//功能:顯示文件創建時信息
''//形參:文件名,信息類別
''// 1 -----創建時間
''// 2 -----上次訪問時間
''// 3 -----上次修改時間
''// 4 -----文件路徑
''// 5 -----文件名稱
''// 6 -----文件類型
''// 7 -----文件大小
''// 8 -----父目錄
''// 9 -----根目錄
''//返回值:成功為文件創建時信息,失敗:-1
''//
Dim f, s
If ReportFileStatus(FileName) = 1 then
Set f = fso.GetFile(FileName)
select Case InfoType
Case 1 s = f.Datecreated ''// 1 -----
創建時間
Case 2 s = f.DateLastAccessed ''// 2 -----上次訪問
時間
Case 3 s = f.DateLastModified ''// 3 -----上次修改
時間
Case 4 s = f.Path ''// 4
-----文件路徑
Case 5 s = f.Name ''// 5
-----文件名稱
Case 6 s = f.Type ''// 6
-----文件類型
Case 7 s = f.Size ''// 7
-----文件大小
Case 8 s = f.ParentFolder ''// 8 -----
父目錄
Case 9 s = f.RootFolder ''// 8 -----
根目錄
End select
ShowFileAccessInfo = s
ELse
ShowFileAccessInfo = -1
End if
End Function
''寫文本文件
Function WriteTxtFile(FileName,TextStr,WriteORAppendType)
Const ForReading = 1, ForWriting = 2 , ForAppending = 8
Dim f, m
select Case WriteORAppendType
Case 1: ''文件進行寫操作
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: ''文件末尾進行寫操作
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
''讀文本文件
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
''建立文本文件
''//==================================目錄操作==================================
''取目錄大小
Function GetFolderSize(FolderName)
''//功能:取目錄大小
''//形參:目錄名
''//返回值:成功為目錄大小,失敗為-1
''//
Dim f
If ReportFolderStatus(FolderName) = 1 Then
Set f = fso.GetFolder(FolderName)
GetFolderSize = f.Size
Else
GetFolderSize = -1
End if
End Function
''創建的文件夾
Function createFolderDemo(FolderName)
''//功能:創建的文件夾
''//形參:目錄名
''//返回值:成功為1,失敗為-1
''//
Dim f
If ReportFolderStatus(Folderspec) = 1 Then
createFolderDemo = -1
Else
Set f = fso.createFolder(FolderName)
createFolderDemo = 1
End if
End Function
''!!!
''目錄刪除
Function deleteAFolder(Folderspec)
''//功能:目錄刪除
''//形參:目錄名
''//返回值:成功為1,失敗為-1
''//
Response.write Folderspec
If ReportFolderStatus(Folderspec) = 1 Then
fso.deleteFolder (Folderspec)
deleteAFolder = 1
Else
deleteAFolder = -1
End if
End Function
''顯示目錄列表
Function ShowFolderList(folderspec)
''//功能:目錄存在時顯示此目錄下的所有子目錄
''//形參:目錄名
''//返回值:成功為子目錄列表,失敗為-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
''!!!!
''目錄復制
Function CopyAFolder(SourceFolder,DestinationFolder)
''//功能:源目錄存在時,才能對目錄進行復制,目的目錄無影響
''//形參:源目錄,目的目錄
''//返回值:成功為1,失敗為-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
''目錄進行移動
Function MoveAFolder(SourcePath,DestinationPath)
''//功能:源目錄存在時目的目錄不存在時才能對目錄進行移動
''//形參:源目錄,目的目錄
''//返回值:成功為1,失敗為-1
''//
If ReportFolderStatus(SourcePath)=1 And ReportFolderStatus(DestinationPath)=0
Then
fso.MoveFolder SourcePath, DestinationPath
MoveAFolder = 1
Else
MoveAFolder = -1
End if
End Function
''判斷目錄是否存在
''Response.Write ReportFolderStatus("G:\soft\delphi\my_pro\")
Function ReportFolderStatus(fldr)
''//功能:判斷目錄是否存在
''//形參:目錄
''//返回值:成功為1,失敗為-1
''//
Dim msg
msg = -1
If (fso.FolderExists(fldr)) Then
msg = 1
Else
msg = -1
End If
ReportFolderStatus = msg
End Function
''目錄創建時信息
Function ShowFolderAccessInfo(FolderName,InfoType)
''//功能:顯示目錄創建時信息
''//形參:目錄名,信息類別
''// 1 -----創建時間
''// 2 -----上次訪問時間
''// 3 -----上次修改時間
''// 4 -----目錄路徑
''// 5 -----目錄名稱
''// 6 -----目錄類型
''// 7 -----目錄大小
''// 8 -----父目錄
''// 9 -----根目錄
''//返回值:成功為目錄創建時信息,失敗:-1
''//
Dim f, s
If ReportFolderStatus(FolderName) = 1 then
Set f = fso.GetFolder(FolderName)
select Case InfoType
Case 1 s = f.Datecreated ''// 1 -----
創建時間
Case 2 s = f.DateLastAccessed ''// 2 -----上次訪問
時間
Case 3 s = f.DateLastModified ''// 3 -----上次修改
時間
Case 4 s = f.Path ''// 4
-----文件路徑
Case 5 s = f.Name ''// 5
-----文件名稱
Case 6 s = f.Type ''// 6
-----文件類型
Case 7 s = f.Size ''// 7
-----文件大小
Case 8 s = f.ParentFolder ''// 8 -----
父目錄
Case 9 s = f.RootFolder ''// 9 -----
根目錄
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 ="指定的文件夾是根文件夾。"&RootFolder
Else
Do Until f.IsRootFolder
Path = Path & f.Name &"<br>"
Set f = f.ParentFolder
n = n + 1
Loop
DisplayLevelDepth ="指定的文件夾是嵌套級為 " & n & " 的文件夾。<br>"&
Path
End If
End Function
''//==================================磁盤操作==================================
''驅動器是否存在?
''Response.Write ReportDriveStatus("C:\")
Function ReportDriveStatus(drv)
''//功能:判斷磁盤是否存在
''//形參:磁盤
''//返回值:成功為1,失敗為-1
''//
Dim msg
msg = -1
If fso.DriveExists(drv) Then
msg = 1
Else
msg = -1
End If
ReportDriveStatus = msg
End Function
''--------可用的返回類型包括 FAT、NTFS 和 CDFS。
''Response.Write ShowFileSystemType("C:\")
Function ShowFileSystemType(drvspec)
''//功能:磁盤類型
''//形參:磁盤名
''//返回值:成功為類型:FAT、NTFS 和 CDFS,失敗:-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
%>
最新更新
unittest的TestCase類提供的判斷方法
python基礎教程之unittest模塊(單元測試)
python基礎教程之Python的特點(優點和缺點
python基礎教程之Python是什么,Python簡介
python基礎教程之編譯型語言和解釋型語言
python基礎教程之編程語言是什么
python基礎教程之Python assert斷言函數及用法
python基礎教程之Python 文件 truncate() 方法
python基礎教程之Python 文件 write() 方法
python基礎教程之Python 文件 writelines() 方法
基于UDP的服務器端和客戶端
再談UDP和TCP
在socket編程中使用域名
網絡數據傳輸時的大小端問題
socket編程實現文件傳輸功能
如何優雅地斷開TCP連接?
圖解TCP四次握手斷開連接
詳細分析TCP數據的傳輸過程
圖解TCP數據報結構以及三次握手(非常詳
TCP協議的粘包問題(數據的無邊界性)
sql語句大全之Microsoft SQL Server 2012安裝說明
sql語句大全之隨機姓名生成方法
sql語句大全之SQL干貨筆記
access數據庫之隨說秋色園從Access升遷到
access數據庫之微信公眾平臺開發(26) ACCE
access數據庫之ACCESS TOKEN
access數據庫之當爬蟲被拒絕時(Access Deni
access數據庫之當爬蟲被拒絕時(Access Deni
access數據庫之使用PowerDesigner生成Access數據
access數據庫之讓ADO.NET Entity Framework 支持