Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Directory content listing

Status
Not open for further replies.

NevG

Programmer
Oct 10, 2000
162
GB
Hi gang

I am tryign to display the contents of a given directory on my asp page. The contents are to be used as links to various downloads and would appreciate being able to do this.

1) Find directory
2) Get contents of directory
3) Put names of files in web page

Thanks 4 any help


Nev G
 
For the questions you ask:

1. Find directory
You should use Server.MapPath(virtual directoty - client request) to map the virtual path to the physical directory.
Then you should check the existence of the physical file or directoryand get its attributes to see if it is a directory with GetFileAttributes.

2.To read the content:
you create a FSO(FileSystemObject) with
Dim MyFSO
set MyFSO=Server.Create("Scripting.FileSystemObject")

Inside this object you have two collections Files and SubFolders as properties:

{example of Files usage}
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & &quot;<BR>&quot;
Next

To display the results in a html page, you have to integrate the code above with <TABLE>,<TR>,<TD> html tags in order to give the result a nice appearence.

Hope thisa helps,

s-)

Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
Hi,

I have the same question as NevG's--just want to display the content of a specific directory , but it still now work after following the steps provided by IonelBurtan. The browser just hang there without any response. Here is my code, and could you tell my is there anything I miss ? Or do I have to do some settings on my iis server?

Thanks a lot!



<html>
<body>
<%
Dim fso, f, f1, fc, s
Set fso = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set f = fso.GetFolder(&quot;C:\tmp&quot;)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & &quot;<BR>&quot;
Next
Response.Write s
%>
</body>
</html>
 
It's really nice of you to introduce me that useful web site. Thanks a lot, Tim!

But I finally found where my problem was, it's my Norton Anit-Virus 2001. FileSystemObject works well after uninstalling NAV 2001-- NAV will change something to which the FileSystemObject refers in your registry.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top