home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 40 / IOPROG_40.ISO / SOFT / asp / FILE.ZIP / ASPFILE.ASP next >
Encoding:
Text File  |  1997-07-16  |  3.7 KB  |  91 lines

  1. <html>
  2. <head><title>AspLib - File Library Examples</title></head>
  3. <body bgcolor=white>
  4. <blockquote>
  5.  
  6. <%
  7.   cReadOnly = &h1
  8.   cHidden   = &h2
  9.   cSysFile  = &h4
  10.   cVolumeID = &h8
  11.   cDirectory = &h10
  12.   cArchive  = &h20
  13.   cAnyFile  = &h3F
  14.  
  15.   Function GetAttrs(intAttrs)
  16.     strAttrs = ""
  17.     if cReadOnly and intAttrs then strAttrs = strAttrs  & "R"
  18.     if cHidden and intAttrs then strAttrs = strAttrs  & "H"
  19.     if cSysFile and intAttrs then strAttrs = strAttrs  & "S"
  20.     if cVolumeID and intAttrs then strAttrs = strAttrs  & "V"
  21.     if cDirectory and intAttrs then strAttrs = strAttrs  & "D"
  22.     if cArchive and intAttrs then strAttrs = strAttrs  & "A"
  23.     GetAttrs = strAttrs
  24.   End Function
  25.  
  26.   Sub ShowFiles (strTitle, strPath, strMask)
  27.     aryFileList = FileObj.GetFileList(strPath, strMask, true)
  28.     if VarType(aryFileList) <> vbNull And IsEmpty(aryFileList) <>  True then
  29.       Response.Write "<p><table border=1 width=500>"
  30.       Response.Write "<tr><td colspan=5 align=center><font size=+1>" & strTitle & "</font></td></tr>"
  31.       Response.Write "<tr><td>File</td><td>Name</td><td>Date</td><td>Size</td><td>Attributes</td></tr>" & vbCrLf
  32.       intArrayLimit = UBound(aryFileList)
  33.       for intCount = 0 to intArrayLimit -1
  34.         Response.Write "<tr><td align=left>" & intCount + 1 & "</td><td align=left>" & _
  35.                        aryFileList(intCount)(0) & "</td><td align=left>" & _
  36.                        aryFileList(intCount)(1) & "</td><td align=left>" & _
  37.                        aryFileList(intCount)(2) & "</td><td align=left>" & _
  38.                        GetAttrs(aryFileList(intCount)(3)) & "</td></tr>" & vbCrLf
  39.       next
  40.       Response.Write "</table>"
  41.     end if
  42.   End Sub
  43.  
  44.   rem *****************************************************************
  45.   rem * Instantiate the object
  46.   rem *****************************************************************
  47.   Set FileObj = Server.CreateObject("AspFile.FileObj")
  48.  
  49.  
  50.   rem *****************************************************************
  51.   rem * Get the Win32 Temp Path and create an empty file of 10212 bytes
  52.   rem * If file creation is succesful then check the file's date/time
  53.   rem *****************************************************************
  54.   strTempFile1 = lcase(FileObj.GetTempPath & "aspfltst.txt")
  55.   Response.Write "Attempting to create temp file " & strTempFile1 & "<br>"
  56.   if FileObj.CreateFileOfSize(strTempFile1, 10212) then
  57.     Response.Write "The file was created.<br>The file's date/time is " & FileObj.GetFileDateTime(strTempFile1, "mm/dd/yy 'at' hh:mm am/pm") & "<br>"
  58.   else
  59.     Response.Write "<p>Unable to create temporary file.<br>"
  60.   end if
  61.  
  62.   rem *****************************************************************
  63.   rem * Copy our temporary file to another and then delete both of them
  64.   rem *****************************************************************
  65.   if FileObj.FileExists (strTempFile1) then
  66.     strTempFile2 = lcase(FileObj.GetTempPath & "aspfltst2.txt")
  67.     if FileObj.CopyFile (strTempFile1, strTempFile2) then
  68.       Response.Write "File was successfully copied to " & strTempFile2 & "<br>"
  69.     end if
  70.     if FileObj.DeleteFile(strTempFile1) then
  71.       Response.Write "The file " & strTempFile1 & " was deleted.<br>"
  72.     end if
  73.     if FileObj.DeleteFile(strTempFile2) then
  74.       Response.Write "The file " & strTempFile2 & " was deleted.<br>"
  75.     end if
  76.   end if
  77.  
  78.   rem *****************************************************************
  79.   rem * Dump a couple of directory listings to the client
  80.   rem *****************************************************************
  81.   ShowFiles "All Files", "C:\", "*.*"
  82.   ShowFiles "Text Files", "C:\", "*.txt"
  83.  
  84.  
  85.   Set FileObj = nothing
  86. %>
  87.  
  88. </blockquote>
  89. </body>
  90. </html>
  91.