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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Files in Current directory

Status
Not open for further replies.

ravula2000

IS-IT--Management
Mar 8, 2002
205
0
0
US
How can I get the files in the current directory using ASP.

For ex - I have some files including listfiles.asp in c:\mydir1\mydir2. Now this file listfiles.asp should list all the files existing in that directory..



Please help

Thanks
Srinivas
 
loop through for each object in the directory
eg:
Set Folder = objFSO.GetFolder(path)
For Each File in Folder.Files
objFile.Name
Next

1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
Basically you will want to use the FileSystemObject to load the target folder, then loop through the .Files collection of your folder object, outputting each .name for each file.

Information on these objects can be found at w3schools here:

-Tarwn

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
minilogo.gif alt=tiernok.com
The never-completed website
 
gah, not only listed the same link as I did, but beat me to it :p
dangit onpnt :)
 
[rofl2]

now we know why I'm where I am. and even while getting older!

1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.GetFolder()

What should be in () to indicate the current folder.. Is there some thing like wild char..?

Thanks
srini
 
the path to the directory
or Server.MapPath(name of diretory)

read the article on the links

1H 1K 10 3D 3F 3E 3K 38 3J 10 1T 10 3G 3L 3I 35 10 35 3O 33 35 3C 3C 35 3E 33 35

onpnt2.gif
 
What if I want to get the listing of files in BOTH directories, c:\mydir1\ and c:\mydir1\mydir2?

Do I have to run the line set f=fs.GetFolder()twice, ie
set f=fs.GetFolder("c:\mydir1") and then set f=fs.GetFolder("c:\mydir1\mydir2") ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top