<% '8***********************************************8 ' Jason Withrow - For ASP101 July 2001 ' Page Builds List of Files in Specific Folder ' With Links to Download files ' ' jwithrow@mediaone.net '8***********************************************8 Dim strThisPage strThisPage = Request.ServerVariables("SCRIPT_NAME") strThisPage = Right(strThisPage, Len(strThisPage) - 1) 'Path To Folder That holds Files To Download Here 'Default is the current Folder FILE_FOLDER = StripFileName(Request.ServerVariables("PATH_TRANSLATED")) %> File Download List For <%= Date() %> <% GetAllFiles %>
File Name File Type File Size File Path Last Modified
<% '8*****************************************8 ' The next release will have sort routines ' That is why the column headers are links ' They are hooks to add the sorts into. '8****************************************8 Sub GetAllFiles() Dim oFS, oFolder, oFile Set oFS = Server.CreateObject("Scripting.FileSystemObject") 'Set Folder Object To Proper File Directory Set oFolder = oFS.getFolder(FILE_FOLDER) Dim intCounter Dim FileArray() intCounter = 0 ReDim Preserve FileArray(oFolder.Files.Count, 5) For Each oFile in oFolder.Files strFileName = oFile.Name strFileType = oFile.Type strFileSize = oFile.Size strFilePath = oFile.Path strFileDtMod = oFile.DateLastModified FileArray(intCounter, 0) = strFileName FileArray(intCounter, 1) = "" & strFileName & "" FileArray(intCounter, 2) = strFileType FileArray(intCounter, 3) = strFileSize FileArray(intCounter, 4) = strFilePath FileArray(intCounter, 5) = strFileDtMod intCounter = (intCounter + 1) Next EchoB("" & oFolder.Files.Count & " Files Available") intRows = uBound(FileArray, 1) intCols = uBound(FileArray, 2) For x = 0 To intRows -1 Echo("") For z = 0 To intCols If z > 0 Then BuildTableCol(FileArray(x, z)) End IF Next Echo("") Next Cleanup oFile Cleanup oFolder Cleanup oFS End Sub Function Echo(str) Echo = Response.Write(str & vbCrLf) End Function Function EchoB(str) EchoB = Response.Write(str & "
" & vbCrLf) End Function Sub Cleanup(obj) IF isObject(obj) Then Set obj = Nothing End IF End Sub Function StripFileName(strFile) StripFileName = Left(strFile, inStrRev(strFile, "\")) End Function Sub BuildTableCol(strData) Echo("" & strData & "") End Sub 'Not implemented Sub BuildTableRow(arrData) Dim intCols intCols = uBound(arrData) For y = 0 To intCols Echo("" & arrData(y) & "") Next End Sub %>