Listing directory from database in order and showing sub folders and files. Classic ASP
I know there are solutions out there for showing a windows directory of folders and files but mine is from a virtual directory within a database.
I have it so far that when you click a show me button it shows the directory path you are in
e.g. folder 1.1.1 folder 1.1 fold开发者_运维知识库er 1it displays in this order but i want it to display the main directory at the top. I would also like to be able to make the list of files clickable so that you can go straight to a specific file or folder when you click the show me button to make it easier for users to find the file they want. Is it possible to display sub-directories without been inside them?
My code for displaying the directory path you are in is:
dim previousPos
previousPos = 0
dim html
html = ""
if not test.BOF then
do while not objRsU.EOF
'if previousPos = (test.Fields(2)) then
response.Write html & "<br />"
html = ""
'else
html = test.Fields(0) & "\" & html
'end if
previousPos = test.Fields(2)
test.MoveNext
loop
end if
set test =nothing
set try =nothing
ListFolderContents Server.MapPath("/"), 0
sub ListFolderContents(path, level)
dim fs, folder, file, item, subFolders
set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)
if folder.SubFolders.Count > 0 or folder.Files.Count > 0 then
'Display the target folder and info.
if level > 3 then
Response.Write("<h2>"& folder.Name &"</h2>" & html)
end if
'Display a list of sub folders.
for each item in folder.SubFolders
ListFolderContents item.Path, level + 1
next
'Display a list of files.
Response.Write("<a<ul></a>" & html)
for each item in folder.Files
Response.Write("<li><a href=""" & test.Name & """>" & try.Name & "</a></li>")
next
Response.Write("</ul>" & html)
end if
end sub
This second part of the code displays the Main folder of the directory.
Any help would be very much appreciated.
Thanks
Why don't you just use something like this instead? It supports Classic ASP.
http://ckfinder.com/
精彩评论