Unique Code Example--Using FileSystemObject to list Directory's on local computer or Remote Share

Using FileSystemObject to list Directory's on local computer or Remote Share Ever need to populate a dropdown box or list a set of folders on the local computer ora remote share?  Here is the code for this!  This is very handy for admin's or ...

Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 8
November 20, 1999
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Using FileSystemObject to list Directory's on local computer or Remote Share


Ever need to populate a dropdown box or list a set of folders on the local computer or a remote share?  Here is the code for this!  This is very handy for admin's or when using Index Server to Narrow your search to a specific directory. You could easily build a string out of this code and use in a dropdown or list box. 

 

Code for getting off a remote share. 

Few things to remember if this share is on another computer in the same domain.  The anonymous account used by your IIS web needs to be an domain user account and have rights to that share. 

<% @language="vbscript" %>
<% folderspec = ("\\Computername\SshareName$")

Dim fs, f, f1, s, sf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
s = s & f1.name
s = s & vbCrLf
Next
Response.Write s
%>

Code for getting off the local computer

You don't have to change the anonymous account used on the IIS web if the folders are listed on this computer.

<% @language="vbscript" %>
<% folderspec = ("c:\DirectoryName\")

Dim fs, f, f1, s, sf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 In sf
s = s & f1.name
s = s & vbCrLf
Next
Response.Write s
%>

blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials