asp的文件处理,查看文件大小类型创建时间
[ 2015-11-09 15:51:18 | 作者: admin ]
获取文件SIZE
'==================================================
'过程名:showsize
'获取文件大小
' filesize = GetFileSize("123.rar")
'==================================================
Function GetFileSize(filename)
FPath=server.mappath(filename) '本目录下
set fso=server.CreateObject("scripting._fso")
If fso.fileExists(FPath) Then
Set f = fso.GetFile(FPath)
filetype=f.type
filesize=f.size
adddate=f.DateCreated
GetFileSize = filesize
else
'Response.Write"文件不存在!"
GetFileSize = 0
end if
End Function
文件信息
评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=2294
'==================================================
'过程名:showsize
'获取文件大小
' filesize = GetFileSize("123.rar")
'==================================================
Function GetFileSize(filename)
FPath=server.mappath(filename) '本目录下
set fso=server.CreateObject("scripting._fso")
If fso.fileExists(FPath) Then
Set f = fso.GetFile(FPath)
filetype=f.type
filesize=f.size
adddate=f.DateCreated
GetFileSize = filesize
else
'Response.Write"文件不存在!"
GetFileSize = 0
end if
End Function
文件信息
<%
Function showFileInfo(filename)
FPath=server.mappath(filename) '本目录下
set fso=server.CreateObject("scripting.filesystemobject")
If fso.fileExists(FPath) Then
Set f = fso.GetFile(FPath)
filetype=f.type
filesize=f.size
adddate=f.DateCreated
Select Case true
Case filesize<1024
fsize=filesize&" B"
Case filesize<1048576
fsize=Round((filesize/1024),2)&" KB"
Case filesize<1073741824
fsize=Round((filesize/1024/1024),2)&" MB"
Case else
fsize=Round((filesize/1024/1024/1024),2)&" GB"
End Select
Response.Write "文件大小:"&fsize&",文件类型:"&filetype&",创建时间:"&adddate
else
Response.Write"文件不存在!"
end if
End Function
%>
<%Call showsize("123.rar")%>
Function showFileInfo(filename)
FPath=server.mappath(filename) '本目录下
set fso=server.CreateObject("scripting.filesystemobject")
If fso.fileExists(FPath) Then
Set f = fso.GetFile(FPath)
filetype=f.type
filesize=f.size
adddate=f.DateCreated
Select Case true
Case filesize<1024
fsize=filesize&" B"
Case filesize<1048576
fsize=Round((filesize/1024),2)&" KB"
Case filesize<1073741824
fsize=Round((filesize/1024/1024),2)&" MB"
Case else
fsize=Round((filesize/1024/1024/1024),2)&" GB"
End Select
Response.Write "文件大小:"&fsize&",文件类型:"&filetype&",创建时间:"&adddate
else
Response.Write"文件不存在!"
end if
End Function
%>
<%Call showsize("123.rar")%>
[最后修改由 admin, 于 2015-11-09 15:53:55]

这篇日志没有评论。
此日志不可发表评论。