<% ' return image for filename association (emulate windows) ' if you pass it "dir", it assumes that the corresponding item is a directory and shows the folder icon. function showimagefortype(strname) dim strtemp ' set our working string to the one passed in strtemp = strname ' if it's not a directory, get the extension and set it to strtemp ' if it is a directory, then we already have the correct value if strtemp <> "dir" then strtemp = lcase(right(strtemp, len(strtemp) - instrrev(strtemp, ".", -1, 1))) end if 'debugging line used to perfect that above string parser 'response.write strtemp ' set the part of the image file name that's unique to the type of file ' to it's correct value and set this to strtemp. select case strtemp case "asp" : strtemp = "asp" case "avi", "mov", "qt", "rm", "wma", "mp3", "mpeg", "mpg" : strtemp = "media" case "exe", "com" : strtemp = "app" case "dir" : strtemp = "dir" case "doc", "rtf" : strtemp = "doc" case "fon", "ttf" : strtemp = "fon" case "htm", "html" : strtemp = "htm" case "gif" : strtemp = "gif" case "png" : strtemp = "png" case "jpg" : strtemp = "jpg" case "txt", "inf" : strtemp = "txt" case "mdb", "db" : strtemp = "mdb" case "pdf" : strtemp = "pdf" case "psd" : strtemp = "psd" case "rar" : strtemp = "rar" case "txt" : strtemp = "txt" case "xls" : strtemp = "xls" case "zip", "tar" : strtemp = "zip" case else : strtemp = "unknown" end select ' all my small icons start with "icon_" (duh) and end with one of the values set in the select statement above. strtemp = "" ' set return value and exit function showimagefortype = strtemp end function %> <% ' runtime code: dim strpath 'path of directory to display dim objfso 'filesystemobject variable dim objfolder 'folder variable dim objitem 'variable used to loop through the contents of the folder ' this needs to end with the / strpath = "./" ' create our file system object set objfso = server.createobject("scripting.filesystemobject") ' get a handle on our folder set objfolder = objfso.getfolder(server.mappath(strpath)) ' show a little description line and the title row of our table %> Christopher Lee Street: Directory
Directory Browser
Current folders and/or files are as follows:

<% ' first folders. display them and when you ' click you go to them via plain http. you might want to loop them back ' through this file once you've set it up to take a path as input. it seems ' like the logical thing to do to me at least! for each objitem in objfolder.subfolders ' deal with the stupid vti's that keep giving our visitors 404's if instr(1, objitem, "_vti", 1) = 0 then %> <% end if next 'objitem %> <% ' first folders. display them and when you ' click you go to them via plain http. you might want to loop them back ' through this file once you've set it up to take a path as input. it seems ' like the logical thing to do to me at least! for each objitem in objfolder.subfolders ' deal with the stupid vti's that keep giving our visitors 404's if instr(1, objitem, "_vti", 1) = 0 then %> <% end if next 'objitem ' now that i've done the subfolders, do the files! for each objitem in objfolder.files %> <% if objitem.name <> "default.asp" then %> <% end if %> <% next 'objitem ' all done! kill off our object variables. set objitem = nothing set objfolder = nothing set objfso = nothing %>
File Type Created Age Size
<%= showimagefortype("dir") %> .. Previous n/a ······ n/a
<%= showimagefortype("dir") %> <%= objitem.name %> <%= objitem.type %> <%= lcase(objitem.datecreated) %> <%= howold(objitem.datecreated,now()) %> <%= bytesize(objitem.size) %>
<%= showimagefortype(objitem.name) %> <%= objitem.name %> <%= objitem.type %> <%= lcase(objitem.datecreated) %> <%= howold(objitem.datecreated,now()) %> <%= bytesize(objitem.size) %>