|
-
Dec 10th, 2000, 04:52 PM
#1
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?
-
Dec 10th, 2000, 07:54 PM
#2
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.
-
Dec 10th, 2000, 08:54 PM
#3
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>
-
Dec 10th, 2000, 08:57 PM
#4
Im displaying the files to a page, I need to sort them within the for loop somehow.
-
Dec 10th, 2000, 09:08 PM
#5
-
Dec 11th, 2000, 02:17 AM
#6
Conquistador
you could look around some other sites to see if they can do it, i.e http://www.4guysfromrolla.com
-
Mar 15th, 2002, 04:50 PM
#7
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 : 
-
Mar 18th, 2002, 06:02 PM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|