Codefixer - ASP tutorials, resources and software
ASP.NET Hosting with US & UK Data Centers!
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Sunday 7 September
MembersPro PayPal - ASP Membership software

New MS SQL 2008 Available – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

Show all Files in a Folder using the FileSystemObject

The example code below will display all the files that reside in the folder 'images' located in the root folder.

<%
Dim oFilesys, oFolder, oFile
Set oFilesys= CreateObject("Scripting.FileSystemObject")
Set oFolder= oFilesys.GetFolder(Server.MapPath("/images/"))
For Each oFile in oFolder.Files
Response.write oFile.Name
Response.write "<br />"
Next

Set oFolder=Nothing
Set oFilesys=Nothing
%>

The example code below will display all the files that reside in the folder in which this script resides.

<%
Dim oFilesys, oFolder, oFile, oFileItem
Dim sPathInfo, sPhysicalPath
sPathInfo=Request.ServerVariables("PATH_INFO")
sPhysicalPath=Server.MapPath(sPathInfo)

Set oFilesys= CreateObject("Scripting.FileSystemObject")
Set oFile=oFilesys.GetFile(sPhysicalPath)
Set oFolder= oFile.ParentFolder
For Each oFileItem in oFolder.Files
Response.write oFileItem.Name
Response.write "<br />"
Next

Set oFolder=Nothing
Set oFilesys=Nothing
%>





If you have any code snippets to share with full credit given then send an email to Codesnippets - You'll receive full credit and a link back to your site.

ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software