All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
Uses,file,scripting,library,list,files,direct
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 287,569. lines
 Jobs: 118. postings

 How to support the site

 
Sponsored by:
Quick Search for:  in language:    
You are in:
 
Login


 

 


Latest postings for ASP/ VbScript.
A simpla ASP Login & Logout Page of E-commerce website for Registred Users
By SJPVTLTD.COM on 2/2


A simplem ASP Login Page for Registered User
By SJPVTLTD.COM on 2/2


Click here to see a screenshot of this code!The Real Estate - Search Engine
By Talal Hussain Al-Balushi on 2/1

(Screen Shot)

A simple ASP Registeration Page for E-commerce Website
By Tejas Jayantilal Gandhi on 1/28


A simple ASP Forgot Password page for E-commerce Website
By Tejas Jayantilal Gandhi on 1/28


Simple ASP inquiry form for a simple or e-commerce website
By Tejas Jayantilal Gandhi on 1/28


A Simple ASP Change of Password Page for E-commerce Website
By Tejas Jayantilal Gandhi on 1/28


A simple ASP Login Page
By Tejas Jayantilal Gandhi on 1/27


Free ASP Shopping Cart Software for Small Business
By Tejas Jayantilal Gandhi on 1/27


ASP Daily Hit Counter
By Tejas Jayantilal Gandhi on 1/27


AS400 Connection
By Talal Hussain Al-Balushi on 1/26


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

List all files in a directory

Print
Email
 
VB icon
Submitted on: 2/19/2000
By: Ian Ippolito (RAC)  
Level: Intermediate
User Rating: By 11 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 61317 times.
 
author picture
(About the author)
 
     Uses the new file FileSystemObject in the scripting library to list all the files in the c:\inetpub\scripts\ directory with a link to them. You can modify this code to list all the files in any directory.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: List all files in a directory
    ' Description:Uses the new file FileSyst
    '     emObject in the scripting library to lis
    '     t all the files in the c:\inetpub\script
    '     s\ directory with a link to them. You ca
    '     n modify this code to list all the files
    '     in any directory.
    ' By: Ian Ippolito (RAC)
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=44&lngWId=4    'for details.    '**************************************
    
    <%@ Language=VBScript %>
    <HTML>
    <BODY>
    <%
    Dim objFileScripting, objFolder
    Dim filename, filecollection, strDirectoryPath, strUrlPath
    	strDirectoryPath="c:\inetpub\scripts\"
    	strUrlPath="\scripts\"
    	
    	'get file scripting object
    	Set objFileScripting = CreateObject("Scripting.FileSystemObject")
    	'Return folder object
    	Set objFolder = objFileScripting.GetFolder("c:\inetpub\scripts\")
    	'return file collection In folder
    	Set filecollection = objFolder.Files
    	'create the links
    	For Each filename In filecollection
    		Filename=right(Filename,len(Filename)-InStrRev(Filename, "\"))
    		Response.Write "<A HREF=""" & strUrlPath & filename & """>" & filename & "</A><BR>"
    	Next
    %>
    </BODY>
    </HTML>


Other 34 submission(s) by this author

 

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
6/6/2000 11:39:38 AMBill Morris

Exactly what I needed this morning. The code is efficient, and provided a great starting point.
(If this comment was disrespectful, please report it.)

 
7/2/2000 9:40:11 PMGuillermo Pensotti

I`m trying to list the files in a directory but I' don`t have the local path, I only have the UNC path (\\server\shared_folder) I´ve tryied with the FileSystemObject but didn´t work. Do you know how to do that??ThanksGuillermo Pensottigsp@cmsrl.com.ar
(If this comment was disrespectful, please report it.)

 
7/3/2000 11:10:27 AMIan Ippolito

Guillermo,

Can you map a drive to it? If so, then you could use the drive letter, (i.e. z:/...) and the file system object will work fine.

Ian
(If this comment was disrespectful, please report it.)

 
10/13/2000 5:15:28 AMStuFF

I have the same
(If this comment was disrespectful, please report it.)

 
10/13/2000 5:19:57 AMStuFF

I have the same "UNC" problem, and I would like to find a solution that doesn't oblige me to map a drive.. Imagine if I have to map 20 drives likes that ;) Or is it possible to map a drive temporary, only for the time of the use of the FSO ?
(If this comment was disrespectful, please report it.)

 
8/31/2001 5:42:57 PMDeryck H

This code needs more commenting. Once accomplished I will rate pretty good (5 star)
(If this comment was disrespectful, please report it.)

 
4/2/2002 1:15:20 PMknowntobe

great code!
Dont suppose you could add paging?? i.e. only show 10 files then have a "view next 10" etc etc. I dont have a clue where to start so shoot me ;o)
(If this comment was disrespectful, please report it.)

 
4/3/2002 9:39:30 AMmark

Is it possible to sort the displayed items
(If this comment was disrespectful, please report it.)

 
4/3/2002 10:01:39 AMIan Ippolito (psc)

Yes you can sort them on your own, but as far as I know not through the file system object.

Ian
(If this comment was disrespectful, please report it.)

 
6/13/2002 2:25:35 PMTony Spencer

Read the following article and it will explain the issues of using Filesystemobject with UNC paths and how to correct the problem.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q197964

In a nutshell, the filesystemobject through ASP is connecting to other servers as IUSR_webservername. That User must have access to the UNC path in order for the filesystemobject to read the files. I hope that helps.
(If this comment was disrespectful, please report it.)

 
10/28/2002 9:33:49 AM

Not so excellent as you say... Take a look at any VBS virus code, and you'll find exactly the same scheme, and also a starting point on how to sort your files...

(If this comment was disrespectful, please report it.)

 
2/8/2003 7:57:08 PMpcdebb

Ian this was a lifesaver. The snippet of code I needed to make my asp page just right!! As always you come thru ;-)
(If this comment was disrespectful, please report it.)

 
2/8/2003 11:53:55 PMIan Ippolito (RAC)

Awesome...glad to hear it! ;)
(If this comment was disrespectful, please report it.)

 
4/28/2003 6:08:56 PM

Just what I was looking for.

As they say, "Worked right out of the box..."
(If this comment was disrespectful, please report it.)

 
4/28/2003 6:22:16 PMIan Ippolito (RAC)

glad to hear it. :)
(If this comment was disrespectful, please report it.)

 
6/21/2003 5:28:55 PM

Just what I needed! I had a similar little script but I needed one that would allow me to write in the physical path. This is nice, thanks.
(If this comment was disrespectful, please report it.)

 
6/21/2003 9:34:30 PMIan Ippolito (RAC)

Glad to hear it's useful for you and thanks! :)
(If this comment was disrespectful, please report it.)

 
4/20/2004 4:12:16 PM

Ian,

Very useful code thank you, really, works like a charm (Tested on Linux Slackware 9 with Sun Java System ASP aka. Chili!Soft aka. Sun ONE ASP).

I have just a small question about it :)

I need to get a couple of dirs all the subdirs inside them, and all the files in each subdir.

I'm testing it right now, but I'm possitive I won't find a quick solution.

Thanks for your time and help =)
(If this comment was disrespectful, please report it.)

 
4/20/2004 4:27:21 PMIan Ippolito (RAC)

What you're looking for is a recursive function which is beyond the scope of this posting. I did post a recursive folder crawler on the VB section of the site, but I don't think I've taken the time to make it 100% ASP compatible. However I believe many others have posted things like that here...so just do a 'search' for it. Good luck.

Ian
(If this comment was disrespectful, please report it.)

 
1/13/2006 9:34:05 AMviralbhatt

Thank you for your code, I really find it usefull. I have one question. Is it possible to display file size or datecreated ?


(If this comment was disrespectful, please report it.)

 
3/21/2007 8:19:55 AMhtl

another greate simple solution
for vb script: open a folder & list its files
can be found here
http://mo8blog.wordpress.com/2007/03/04/vb-script-open-a-folder-list-its-files/
(If this comment was disrespectful, please report it.)

 
4/18/2007 7:18:12 PMcobbr

Excellent!!! 5 Globes!! Your Code is a must for VBSCRIPTING!
(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Games | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2010 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.