文件、目录,文本文件等多种操作类(4)
时间
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)
内容版权声明:除非注明,否则皆为本站原创文章。