home *** CD-ROM | disk | FTP | other *** search
/ Internet Pratica / IPRAT_01.iso / ASP / FileFunctions / FILEFUNC.ASP < prev    next >
Encoding:
Text File  |  1997-12-14  |  4.4 KB  |  182 lines

  1. <!--
  2.  
  3.          ASP FileFunctions Demo by J. Ritmeijer
  4. For more info check out http://wwww.xs4all.nl/~jarit/asp/
  5.  
  6. -->
  7.  
  8.  
  9. <%    
  10. sub PrintList()
  11.     Sort = Request("sort")
  12.     Order = Request("order")
  13.     if Sort <> "" then
  14.         FFunc.sort Sort,Order
  15.     end if
  16.  
  17.     response.write("<TABLE WIDTH='100%' BORDER=1 CELLPADDING=4 CELLSPACING=0 BGCOLOR='white' BORDERCOLOR='black'>")
  18.     response.write("<TR BGCOLOR='#cc6666'><TD><B>Path</B></TD>")
  19.     response.write("<TD><B>Filename</B></TD>")
  20.     response.write("<TD ALIGN='right'><B>Size</B></TD>")
  21.     response.write("<TD><B>Modified date</B></TD>")
  22.     response.write("<TD><B>Attributes</B></TD></TR>")
  23.     s = ""
  24.     For i = 1 to ffunc.count
  25.         response.write("<TR VALIGN='TOP'><TD WIDTH='15%'>" & FFunc(i).Path & " </TD>")
  26.         response.write("<TD WIDTH='30%'>" & FFunc(i).name & " </TD>")
  27.         response.write("<TD WIDTH='15%' ALIGN='right'>" & formatnumber(FFunc(i).Size,false,true) & " </TD>")
  28.         response.write("<TD WIDTH='30%'>" & FFunc(i).Modified & " </TD>")
  29.         response.write("<TD WIDTH='10%'>" & FFunc(i).Attributes & " </TD></TR>")
  30.     Next
  31.     response.write "</TABLE><P>"
  32. end sub
  33. %>
  34.  
  35. <HTML>
  36. <HEAD>
  37.     <TITLE>ASP Filefunctions Demo</TITLE>
  38. </HEAD>
  39.  
  40. <BODY BGCOLOR="#ffffcc">
  41.  
  42.  
  43. <H1>FileFunctions Demo</H1>
  44.  
  45. <B>Sort ascending on:</B> 
  46. <A HREF="filefunc.asp?sort=path&order=ascending">Path</A>, 
  47. <A HREF="filefunc.asp?sort=name&order=ascending">Name</A>, 
  48. <A HREF="filefunc.asp?sort=extension&order=ascending">Extension</A>, 
  49. <A HREF="filefunc.asp?sort=size&order=ascending">Size</A>, 
  50. <A HREF="filefunc.asp?sort=modified&order=ascending">Modified</A>, 
  51. <A HREF="filefunc.asp?sort=attributes&order=ascending">Attributes</A>
  52. <BR>
  53. <B>Sort descending on:</B> 
  54. <A HREF="filefunc.asp?sort=path&order=descending">Path</A>, 
  55. <A HREF="filefunc.asp?sort=name&order=descending">Name</A>, 
  56. <A HREF="filefunc.asp?sort=extension&order=descending">Extension</A>, 
  57. <A HREF="filefunc.asp?sort=size&order=descending">Size</A>, 
  58. <A HREF="filefunc.asp?sort=modified&order=descending">Modified</A>, 
  59. <A HREF="filefunc.asp?sort=attributes&order=descending">Attributes</A>
  60. <BR>
  61.  
  62. <P><B><I>Display all directories in c:\</I></B><P>
  63. <%
  64.     set FFunc = Server.createobject("Filefunctions.files")
  65.     
  66.  
  67.     ' FFunc.Path = "\\onyx\data"   ' UNC paths are allowed
  68.     FFunc.path = "c:\"
  69.     FFunc.mask = "*.*"
  70.     FFunc.attributes = 16        ' get only directories
  71.     FFunc.GetFileList()
  72.     PrintList
  73. %>
  74.  
  75. <HR>
  76.  
  77. <P><B><I>Display all system files in c:\</I></B><P>
  78. <%   
  79.     FFunc.clearfilelist
  80.     FFunc.attributes = 4
  81.     FFunc.GetFileList("c:\*.*")
  82.     PrintList
  83. %>
  84.  
  85. <HR>
  86.  
  87. <B><I>Make Directory c:\ffuncdir</I></B><P>
  88.  
  89. <%    FFunc.MakeDir("c:\ffuncdir")
  90.     FFunc.clearfilelist
  91.     FFunc.attributes = 16
  92.     FFunc.path = "c:\"
  93.     FFunc.mask = "f*"
  94.     FFunc.GetFileList
  95.     PrintList
  96. %>
  97.  
  98. <HR>
  99.  
  100. <B><I>Rename Directory c:\ffuncdir into c:\ffunc</I></B><P>
  101.  
  102. <%    FFunc.Rename "c:\ffuncdir","c:\ffunc"
  103.     FFunc.clearfilelist
  104.     FFunc.GetFileList
  105.     PrintList
  106. %>
  107.  
  108. <HR>
  109.  
  110. <B><I>move directory c:\ffunc to c:\f\ffunc</I></B><P>
  111.  
  112. <%  FFunc.MakeDir("c:\f")
  113.     FFunc.Rename "c:\ffunc","c:\f\ffunc"
  114.     FFunc.Path = "c:\f"
  115.     FFunc.clearfilelist
  116.     FFunc.GetFileList
  117.     PrintList
  118. %>
  119.  
  120. <HR>
  121.  
  122. <B><I>remove directory c:\f</I></B><P>
  123.  
  124. <%  FFunc.removeDir("c:\f\ffunc")
  125.     FFunc.removeDir("c:\f")
  126.     FFunc.clearfilelist
  127.     FFunc.Path = "c:\"
  128.     FFunc.GetFileList
  129.     PrintList
  130. %>
  131.  
  132. <HR>
  133.  
  134. <B><I>Uncomment source code for killfile demo</I></B><P>
  135.  
  136. <%    ' since I don't want to erase your harddisk, uncomment and adapt the following line
  137.     ' for an example that erases all files and empty directories for a given path.
  138.     'FFunc.clearfilelist
  139.     'FFunc.attributes = -1
  140.     'FFunc.getfilelist("e:\test\*.*")
  141.     'PrintList
  142.     'For each file in ffunc
  143.     '    if not file.killfile then
  144.     '        response.write file.lasterror
  145.     '    end if
  146.     'next
  147.     'FFunc.Clearfilelist
  148.     'FFunc.getfilelist("e:\test\*.*")
  149.     'PrintList
  150. %>    
  151.  
  152. <HR>
  153.  
  154. <B><I>Check for c:\autoexec.bat</I></B><P>
  155. <%    ffunc.path = "c:\"
  156.     ffunc.mask = "autoexec.bat"
  157.     if FFunc.Exists() then
  158.         response.write("<P>exists")
  159.     else
  160.         response.write("<P>does not exist")
  161.     end if
  162. %>    
  163.  
  164. <HR>
  165.  
  166. <B><I>Check for c:\heyyou.txt</I></B><P>
  167. <%    if FFunc.Exists("c:\heyyou.txt") then
  168.         response.write("<P>exists")
  169.     else
  170.         response.write("<P>does not exist")
  171.     end if
  172. %>    
  173.  
  174. <HR>
  175.  
  176. <P>
  177.  
  178. For more info check out the <A HREF="http://www.xs4all.nl/~jarit/asp/">support site</A>.
  179.  
  180. </BODY>
  181. </HTML>
  182.