Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listing of files in a directory

Status
Not open for further replies.

jnabors

Programmer
Jan 12, 2000
1
US
I am developing a web site and would like some code to obtain a list of files in a given directory on the server and allow the user to select from them. Im sure this is quite easy for any VBScript Pros out there, but the solution eludes me. I have checked on MSDN, most reference books I have and online. I cant seem to find anything that will work in conjunction with HTML and Active Server Pages.<br>
<br>
Any suggestions would be greatly appreciated!<br>
<br>
Jay<br>

 
%@ LANGUAGE=&quot;VBSCRIPT&quot;%&gt;<br>&lt;html&gt;<br><br>&lt;head&gt;<br>&lt;title&gt;Liste des fichiers et répertoires&lt;/title&gt;<br>&lt;/head&gt;<br><br>&lt;body&gt;<br>&lt;%<br>encours = request.querystring(&quot;rep&quot;)<br>Parent = &quot;&quot;<br>'ouverture du systeme de fichiers<br>Set Systeme_fichier=Server.createObject(&quot;Scripting.FileSystemObject&quot;)<br>'création de l'objet répertoire<br>Set Repertoire = Systeme_fichier.GetFolder(server.MapPath(parent&encours&&quot;../../&quot;))<br>%&gt;<br><br>&lt;P align=center&gt;&lt;font face=&quot;Arial&quot; size=5&gt;&lt;strong&gt;Liste des fichiers et répertoires&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;<br><br>&lt;hr&gt;<br><br>&lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;100%&quot;&gt;<br>&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;25%&quot; align=&quot;left&quot;&gt;&lt;p align=&quot;left&quot;&gt;&lt;strong&gt;&lt;font face=&quot;Arial&quot;&gt;Nom&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;15%&quot; align=&quot;left&quot; size=&quot;2&quot;&gt;&lt;strong&gt;&lt;font face=&quot;Arial&quot;&gt;Taille&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;25%&quot; align=&quot;left&quot; size=&quot;2&quot;&gt;&lt;strong&gt;&lt;font face=&quot;Arial&quot;&gt;Type&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;20%&quot; align=&quot;left&quot; size=&quot;2&quot;&gt;&lt;strong&gt;&lt;font face=&quot;Arial&quot;&gt;Date&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&lt;/tr&gt;<br>&nbsp;&nbsp;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;% if encours&lt;&gt;&quot;&quot; then %&gt;<br><br>&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;a href=&quot;javascript:history.back()&quot;&gt;&lt;font face=&quot;Arial&quot; size=2&gt;Dossier parent&lt;/font&gt;&lt;/a&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&lt;/tr&gt;<br>&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;% end if %&gt;<br>&lt;%<br>' Tous les sous-répertoires<br>for each Curseur In Repertoire.SubFolders %&gt;<br>&lt;/td&gt;<br>&nbsp;&nbsp;&lt;/tr&gt;<br>&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;a href=&quot;testlist.asp?rep=&lt;%=encours%&gt;/&lt;%=Curseur.name%&gt;&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;font face=&quot;Arial&quot; size=2&gt;&lt;%=Curseur.name %&gt;&lt;/font&gt;&lt;/a&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;15%&quot;&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;Dossier&lt;/font&gt; &lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;20%&quot;&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;%=curseur.DateLastModified%&gt;&lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&lt;/tr&gt;<br>&lt;%next%&gt;<br>&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td colspan=&quot;4&quot;&gt;&lt;hr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/td&gt;<br>&nbsp;&nbsp;&lt;/tr&gt;<br>&lt;%<br>' Tous les fichiers<br>for each Curseur In Repertoire.Files %&gt;<br>&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;%i = i+1<br>if i=1 then response.write(&quot;&lt;font face=Arial size=2&gt;&lt;u&gt;Liste des fichiers :&lt;/u&gt;&lt;/font&gt;&lt;br&gt;&quot;)%&gt;<br>&lt;/td&gt;<br>&nbsp;&nbsp;&lt;/tr&gt;<br>&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;font face=&quot;arial&quot; size=&quot;2&quot;&gt; &lt;a href=&quot;&lt;%=parent%&gt;&lt;%=encours%&gt;/&lt;%=curseur.name%&gt;&quot;&gt;&lt;%=Curseur.name%&gt;&lt;/a&gt;<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;15%&quot; align=left&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;%=formatnumber(curseur.Size/1024,2)%&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;Ko   &lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;%=curseur.Type%&gt;&lt;/font&gt; &lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;td width=&quot;20%&quot;&gt;&lt;font face=&quot;Arial&quot; size=&quot;2&quot;&gt;&lt;%=curseur.DateLastModified%&gt;&lt;/font&gt;&lt;/td&gt;<br>&nbsp;&nbsp;&lt;/tr&gt;<br>&lt;%next%&gt;<br>&lt;/table&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top