%@ Language=VBScript %>
<% ' This function takes a filename and returns the appropriate image for ' that file type based on it's extension. 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. (yet another use of it!) Select Case strTemp Case "asp" strTemp = "asp" Case "dir" strTemp = "dir" Case "htm", "html" strTemp = "htm" Case "gif", "jpg" strTemp = "img" Case "txt" strTemp = "txt" Case "csv" strTemp = "csv" Case Else strTemp = "misc" End Select ' All our logic is done... build the IMG Tag for display to the browser ' Place it into... where else... strTemp! ' My images are all GIFs and all start with "dir_" for my own sanity. ' They end with one of the values set in the select statement above. strTemp = "| File Name: | File Size (bytes): | Date Created: | File Type: |
| <%= ShowImageForType("dir") %> <%= objItem.Name %> | <%= objItem.Size %> | '<%= objItem.DateCreated %> | <%= objItem.Type %> |
| <%= ShowImageForType(rstFiles.Fields("name").Value) %> "><%= rstFiles.Fields("name").Value %> | <%= rstFiles.Fields("size").Value %> | <%= rstFiles.Fields("date").Value %> | <%= rstFiles.Fields("type").Value %> |