Results 1 to 8 of 8

Thread: Displaying a folder's contents alphabetically

  1. #1
    Guest
    I'm displaying a folder's contents and I want to know how to display the files alphabetically. Is this possible? If so, how do I do it?

  2. #2
    Guest
    What are you using to display the folder's contents? A listbox? Just set the Sorted property to True and they will be sorted alphabetically.

  3. #3
    Guest
    a listbox? not at all. I'm doing this:

    <%@ Language="VBScript" %>

    <html>

    <head>

    <%

    'Define the File System Object and set variables

    Dim FSO, Folder, FolderContents, FileItem
    Set FSO = CreateObject("Scripting.FileSystemObject") 'Create FSO
    Set Folder = FSO.GetFolder("C:\muzik\hip-hop - rap") 'Declare folder to have contents displayed
    Set FolderContents = Folder.Files

    %>

    <title><%= Response.Write(Folder.Name) %></title>

    <style type="text/css">

    body, table {color:#000000; font-family:Verdana; font-size:11px}

    </style>

    </head>

    <body>

    <form action="Confirm.asp" method="post">
    <table border="0" cellpadding="4" cellspacing="0">
    <tr><td bgcolor="darkgray" align=left>
    </td><td bgcolor="darkgray" align=left>
    <font size="2"><b>File</b></font>
    </td><td bgcolor="darkgray" align=left>
    <font size="2"><b>Size (mb)</b></font>
    </td></tr>

    <%

    'Display each file's name and size with a checkbox

    Response.Write("<font size=5>Contents of: " & Folder & "<p>")

    Dim FileSize

    For Each FileItem In FolderContents
    FileSize = Round(FileItem.Size / 1000000, 1) 'Converts file size into MB, rounds to tenth place
    Response.Write("<tr><td bgcolor=lightgrey align=left>")
    Response.Write("<input type='checkbox'>")
    Response.Write("</td><td bgcolor=lightgrey align=left>")
    Response.Write(FileItem.Name) 'Displays file name
    Response.Write("</td><td bgcolor=lightgrey align=right>")
    Response.Write(FileSize) 'Displays file size in MB
    Response.Write("</td></tr>")
    Next

    %>

    </td></tr>
    <tr><td colspan=3>
    <input type="submit" value="Delete">
    </td></tr>
    </table>
    </form>

    </body>

    </html>

  4. #4
    Guest
    Im displaying the files to a page, I need to sort them within the for loop somehow.

  5. #5
    Guest
    eek

    I'm still only learning VBScript, only know a limited amount of stuff. This is out of my league for now, sorry .

  6. #6
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    you could look around some other sites to see if they can do it, i.e http://www.4guysfromrolla.com

  7. #7
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Originally posted by voyd1
    Im displaying the files to a page, I need to sort them within the for loop somehow.
    Yep you could use a sort function. First read all the file names to an Array and then use the sort function to sort that array and the output the content of the sorted array.

    You should be able to find plenty of sort algorithm in this forum just adapt it for ASP.

    Shouldnt be that hard.

    Hope this helps
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  8. #8
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    Here is a link, i think this is what exactly you are lookikng for

    http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=118
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width