文件、目录,文本文件等多种操作类
2008-02-23 09:34:36来源:互联网 阅读 ()
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:\ditg\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:\ditg")
'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)&"<br>"
'Response.Write MyFileFolder.ShowFileAccessInfo("f:\123\123.txt",2)&"<br>"
'Response.Write MyFileFolder.ShowFileAccessInfo("f:\123\123.txt",3)&"<br>"
'Response.Write MyFileFolder.ShowFileAccessInfo("f:\123\123.txt",4)&"<br>"
'Response.Write MyFileFolder.ShowFileAccessInfo("f:\123\123.txt",5)&"<br>"
'Response.Write MyFileFolder.ShowFileAccessInfo("f:\123\123.txt",6)&"<br>"
'Response.Write MyFileFolder.ShowFileAccessInfo("f:\123\123.txt",7)&"<br>"
'Response.Write MyFileFolder.ShowFileAccessInfo("f:\123\123.txt",8)&"<br>"
'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",1)&"<br>"
'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",2)&"<br>"
'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",3)&"<br>"
'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",4)&"<br>"
'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",5)&"<br>"
'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",6)&"<br>"
'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",7)&"<br>"
'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",8)&"<br>"
'Response.Write MyFileFolder.WriteTxtFile("f:\123\cexo.txt","",1)&"<br>"
'Response.Write MyFileFolder.WriteTxtFile("f:\123\cexo.txt","cexowxfdw",1)&"<br>"
'Response.Write MyFileFolder.WriteTxtFile("f:\123\cexo.txt",Chr(13)&Chr(10)
&"cexowxfdw",2)&"<br>"
'Response.Write MyFileFolder.ReadTxtFile("f:\123\cexo.txt")&"<br>"
Response.Write MyFileFolder.DisplayLevelDepth("F:\ditg\ditg\bumen\images")&"<br>"
Class FileFolderCls
Public fso
Private Sub Class_Initialize()
Set fso = CreateObject("Scripting.FileSystemObject")
End Sub
Private Sub Class_Terminate()
Set fso = Nothing
End Sub
'//==================================文件操作==================================
'取文件大小
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
'文件移动
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:FSO组件之文件夹操作
下一篇:利用FSO取得图像文件信息
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash