ember Posted September 5, 2006 Share Posted September 5, 2006 hello everyone. i'm a little confused with the results i'm obtaining from the following script: <%CONST DIRECTORY = "/" ' relative path in virtual directories'missing file info fileown = 8 fileat = 10' Specify one of these constants for "sortBy"...CONST FILE_NAME = 0CONST FILE_EXT = 1CONST FILE_TYPE = 2CONST FILE_SIZE = 3CONST FILE_CREATED = 4CONST FILE_MODIFIED = 5CONST FILE_ACCESSED = 6' get requested sort order, if not first time here...' (forward by name is default)req = Request("sortBy")If Len(req) < 1 Then sortBy = 0 Else sortBy = CInt(req)req = Request("priorSort")If Len(req) < 1 Then priorSort = -1 Else priorSort = CInt(req)'' did user ask for same sort? to reverse the order?' but if so, then zap priorSort so clicking again will do forward!If sortBy = priorSort Then reverse = true priorSort = -1Else reverse = false priorSort = sortByEnd If' now start the *real* code...'path = Server.MapPath( DIRECTORY )Set sh = CreateObject("Shell.Application") set fl = sh.Namespace( path )Set fso = CreateObject("Scripting.FileSystemObject")Set theCurrentFolder = fso.GetFolder( path )Set curFiles = theCurrentFolder.Files'' And now a loop for the files'Dim theFiles( )ReDim theFiles( 500 ) ' arbitrary size!currentSlot = -1 ' start before first slot' We collect all the info about each file and put it into one' "slot" in our "theFiles" array.'For Each fileItem in curFiles fname = fileItem.Name fext = InStrRev( fname, "." ) If fext < 1 Then fext = "" Else fext = Mid(fname,fext+1) ftype = fileItem.Type fsize = fileItem.Size fcreate = fl.GetDetailsOf(f,fileat) 'fcreate = fileItem.DateCreated fmod = fileItem.DateLastModified 'faccess = fileItem.DateLastAccessed faccess = fl.GetDetailsOf(f,fileow) currentSlot = currentSlot + 1 If currentSlot > UBound( theFiles ) Then ReDim Preserve theFiles( currentSlot + 99 ) End If ' note that what we put here is an array! theFiles(currentSlot) = Array(fname,fext,ftype,fsize,fcreate,fmod,faccess)Next'' files are now in the array...'' As noted, it is actually an ARRAY *OF* ARRAYS. Which makes' picking the column we will sort on easier!'' ...size and sort it...fileCount = currentSlot ' actually, count is 1 more, since we start at 0ReDim Preserve theFiles( currentSlot ) ' really not necessary...just neater!' First, determine which "kind" of sort we are doing.' (VarType=8 means "string")'If VarType( theFiles( 0 )( sortBy ) ) = 8 Then If reverse Then kind = 1 Else kind = 2 ' sorting strings...Else If reverse Then kind = 3 Else kind = 4 ' non-strings (numbers, dates)End If'' A simple bubble sort for now...easier to follow the code...'For i = fileCount TO 0 Step -1 minmax = theFiles( 0 )( sortBy ) minmaxSlot = 0 For j = 1 To i Select Case kind ' which kind of sort are we doing? ' after the "is bigger/smaller" test (as appropriate), ' mark will be true if we need to "remember" this slot... Case 1 ' string, reverse...we do case INsensitive! mark = (strComp( theFiles(j)(sortBy), minmax, vb script:reSort(0);">File name</A></TH> <TH bgcolor=#CECFCE class=normal align=center><A HREF="java script:reSort(1);">Extension</A></TH> <TH bgcolor=#CECFCE class=normal align=center><A HREF="java script:reSort(2);">Type</A></TH> <TH bgcolor=#CECFCE class=normal align=center><A HREF="java script:reSort(3);">Size</A></TH> <TH bgcolor=#CECFCE class=normal align=center><A HREF="java script:reSort(4);">Author</A></TH> <TH bgcolor=#CECFCE class=normal align=center><A HREF="java script:reSort(5);">Last modified</A></TH> <TH bgcolor=#CECFCE class=normal align=center><A HREF="java script:reSort(6);">Author</A></TH></TR><%' With the array nicely sorted, this part is a piece of cake!For i = 0 To fileCount Response.Write "<TR class=normal>" & vbNewLine For j = 0 To UBound( theFiles(i) ) Response.Write " <TD>" & theFiles(i)(j) & "</TD>" & vbNewLine Next Response.Write "</TR>" & vbNewLineNext%> in the Owner/Author items, instead of returning the info about the file, it returns the type of info, in all files!example:instead of returning this,file | owner | author |1.jpg| ember | e1brpt |2.jgp| bruno |b1brpt |it returns this:file |owner |author |1.jpg |owner |author |2.jpg |owner |author |can anyone help me correct this?thanks in advance, ember Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now