ASP Directory Listing

ASP Directory Listing

To access a folder, you first create a FileSystemObject then use the GetFolder() method specifying the physical path of that folder.

dim fso , folder , file

set fso = CreateObject(”scripting.FileSystemObject”)

set folder = fso.GetFolder(”D:\inetpub\publicstatic\test\UploadedFiles)

To find the path of a file on the local web site, the built-in Server.MapPath() function can be used to translate a URL to a physical path.

path = Server.MapPath(”/UploadedFiles/”)

Which might return “D:\Inetpub\publicstatic\test\UploadedFiles\” for example. This value can then be used in the GetFolder() call. 

Among the Folder object’s properties are the Files and SubFolders collections. These can be enumerated to list the folder contents.

To following sample code will retrieve the list of files from the folder

For each file in folder.Files

Response.Write(file.Name)

Next

 

 

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.