文件、目录,文本文件等多种操作类

80酷酷网    80kuku.com

  

<%
    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)&"
"
    '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.ShowFolderAccessInfo("f:\123\",1)&"
"
    'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",2)&"
"
    'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",3)&"
"
    'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",4)&"
"
    'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",5)&"
"
    'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",6)&"
"
    'Response.Write MyFileFolder.ShowFolderAccessInfo("f:\123\",7)&"
"
    'Response.Write MyFileFolder.ShowFolderAccessInfo("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:\ditg\ditg\bumen\images")&"
"
   
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
&nbs

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: