如何用asp统计一个文件夹 所有文件大小
请高手看看

解决方案 »

  1.   


    uploadPath = "C:\temp"
    if FileObject.FolderExists(uploadPath) then
    Set Folder=FileObject.GetFolder(uploadPath)
    AllSize = Folder.Size
    AllSize=Round(AllSize/1024,2)
    if AllSize < 1 and f>0 then AllSize="0"&AllSize
    '循环显示其中子目录
    For Each thing in Folder.SubFolders
    SubPath = thing
    'response.write uploadPath&"<br>"&thing
    thing = replace(lcase(thing),uploadPath&"\","")
    Foldername=thing
    response.write "子目录名:"&Foldername&"<br>"
    n=0
    fileSize=0
    if FileObject.FolderExists(SubPath) then
    Set Folder2=FileObject.GetFolder(SubPath)
    ''统计子目录中的文件数和大小
    For Each thing2 in Folder2.Files
    n=n+1
    Next
    fileSize = Folder2.Size
    fileSize=Round(fileSize/1024,2)
    if fileSize < 1 and n>0 then fileSize="0"&fileSize
    Set Folder2 = nothing
    End if
    response.write n
    allN = allN+N
    f=f+1
         response.write "文件大小:"&fileSize&"<br>"

    Next
    else
    response.Write(uploadPath&"目录不存在.")
    End if