When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Tuesday, September 29, 1998

VBScript DIR Function


This code was written by Toby Gramm, webmaster of Techfools.com.


DIR


Yep it's kinda like the old school DOS days.

Put this code in a file and name it "dir.asp", make sure that this

- continued -

is used in a secure directory, cuz this has to potenial to expose you whole file system to the Web! Can be very useful, can also shoot you in the foot. Use this wisely!

Example:
http://www.techfools.com/code/dir/dir.asp?PP=G:\InetPub\wwwroot\techfools\code\dir\&UU=http://www.techfools.com/code/dir/
Note: Of course you would URLencode this.

Result:
Folder

code.txt
default.asp
fCount.asp
Sample.asp

Da' Code


<%@ LANGUAGE="VBSCRIPT" %>
<%

'Written by: Toby Gramm
'070698
'Modified 092998 - Added support for Folders.
'		   As suggested by Bill Wilkinson [BillW@chilisoft.com]

Sub Main()
	sPP = Request.QueryString("PP") 'Physical Path
	sUP = Request.QueryString("UP") 'URL Path

	Set fso = CreateObject("Scripting.FileSystemObject")
	Set f = fso.GetFolder(sPP)  
	Set fc = f.Files 
	Set ff = f.SubFolders 
	For Each f1 in ff	
  	  Response.Write "<a href=" & sUP & f1.name & ">" & f1.name & "</a> <br>"
	Next  
	Response.Write "<br>"
	For Each f1 in fc
	  Response.Write "<a href=" & sUP & f1.name & ">" & f1.name & "</a> <br>"
	Next  
	Set ff = nothing
	Set fso = nothing
	Set f = nothing
	Set fc = nothing
End Sub
%>
Main()


[Visit Techfools.com] [Email Webmaster]


ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article