【asp.net】asp 取文件相关信息与取目录相关信息

更新时间:2016-05-24    来源:网络相关    手机版     字体:

【www.bbyears.com--网络相关】

 "参数:文件名(相对路径)
 "返回值:0大小 1创建时间 2最后修改时间 3最后浏览时间 4路径 5类型 6名称
 Public Function GetFileInfo(FileName)
  Dim f,temp
  Dim file(7)
  On Error Resume Next
  temp = Server.Mappath(FileName)
  If oFso.FileExists(temp) Then
   Set f = oFso.Getfile(temp)
   file(0) = Lib.FormatNumberStr(f.Size / 1024,1) &" KB"
   file(1) = Lib.DateFormat(f.DateCreated,"y-M-D H:N:S")
   file(2) = Lib.DateFormat(f.DateLastModified,"y-M-D H:N:S")
   file(3) = Lib.DateFormat(f.DateLastAccessed,"y-M-D H:N:S")
   file(4) = f.Path
   file(5) = f.Type
   file(6) = f.Name
  End If
  If Err <> 0 Then Err.Clear
  GetFileInfo = file
  Set f = Nothing
 End Function

 "作用:取目录相关信息
 "参数:目录名(相对路径)
 "返回值:0大小 1创建时间 2最后修改时间 3最后浏览时间 4路径 5类型 6名称
 Public Function GetfolderInfo(folderName)
  Dim f,temp
  Dim folder(7)
  On Error Resume Next
  temp = Server.Mappath(folderName)
  If oFso.folderExists(temp) = True Then
   Set f = oFso.Getfolder(temp)
   folder(0) = Lib.FormatNumberStr(f.Size / 1024,1) &" KB"
   folder(1) = Lib.DateFormat(f.DateCreated,"y-M-D H:N:S")
   folder(2) = Lib.DateFormat(f.DateLastModified,"y-M-D H:N:S")
   folder(3) = Lib.DateFormat(f.DateLastAccessed,"y-M-D H:N:S")
   folder(4) = f.Path
   folder(5) = f.Type
   folder(6) = f.Name
  End if
  If Err <> 0 Then Err.Clear
  GetfolderInfo = folder
  Set f = Nothing
 End Function

 %>

本文来源:http://www.bbyears.com/jiaocheng/24098.html

猜你感兴趣

热门标签

更多>>

本类排行