您的位置:首页 > 编程语言 > ASP

ASP中获得文件大小的函数

2004-11-05 08:56 363 查看
      以下函数是获得文件大小的函数,具体实现如下:
<%
' Company: Sabra Inc
' Author: Dave Hoffenberg
' Function: Retrieves file size(K) of any file name passed to it.
' Freeware

Function ShowFileSize(filespec)
    file = Server.MapPath(filespec)
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(file) Then
    Set f = fso.GetFile(file)
intSizeB = f.Size
    intSizeK = Int((intSizeB/1024) + .5)
    If intSizeK = 0 Then intSizeK = 1
     ShowFileSize = intSizeK & "k"
Else
 ShowFileSize = "File Doesn't Exist"
End If
Set fso = Nothing
End Function

response.write ShowFileSize("test.txt")
%>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  asp file function