|
Giomanach -> RE: listing folder contents in a browser (3/15/2005 19:40:15)
|
OK, create an ASP page, with this in it: <% 'Putting this file into a directory and calling it will list all the files in the directory as text links with 'relative paths dim FileExt(3) dim AbsolutePath dim Max 'FileExt Holds File Extension, to add new file ext write 'FileExt(4)="gif" 'then change the array dim stat. to 4 and etc... FileExt(0)="txt" FileExt(1)="htm" FileExt(2)="html" FileExt(3)="asp" Max=UBound(FileExt) AbsolutePath = Server.MapPath ("/") ShowFolderList AbsolutePath Sub ShowFolderList(FldPath) Dim fso, f, f1, s, sf Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder(FldPath) Set sf = f.SubFolders For Each f1 in sf s = FldPath & "\" & f1.name ShowFiles s Next End sub Sub ShowFiles(path) dim fs,Dir,n,file set fs=server.CreateObject("Scripting.FileSystemObject") Set Dir=fs.GetFolder(path & "\") for each file in dir.files for n= 0 to Max if Right(file,len(FileExt(n)))=FileExt(n) then MakeLink file end if next next ShowFolderList path end sub Sub MakeLink(path) dim Link path=Mid(path,Len(AbsolutePath)+1) path=Replace(path,"\","/",1) file=path link="<a href=" & chr(34) & file & chr(34) & " title=" & file & ">" & file & "</a><br>" Response.Write link end sub %> That will should list the files, and provide a link to each of them. HTH Dan
|
|
|
|