Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2004, 12:07 PM
sam sam is offline
Authorized User
 
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Alphabetize Folder Contents

I have a function (see below) which returns a select box of the files in a certain folder the problem is it isn't alphabetizes. Any suggestions? If I need to sort it myself if someone has a good sorting algorithm they could post I would appreciate it.
Code:
              
Function opt_getPopUpsFolder(fileLink) 
    Dim strPathInfo, strPhysicalPath, opt
    strPathInfo = "../../PopUps/index.asp"
    strPhysicalPath = Server.MapPath(strPathInfo)

    Dim objFSO, objFile, objFileItem, objFolder, objFolderContents, objsubfol
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set objFile = objFSO.GetFile(strPhysicalPath)
    Set objFolder = objFile.ParentFolder
    Set objFolderContents = objFolder.Files
    Set objsubfol = objFolder.SubFolders
  
    For Each objFileItem in objFolderContents
        IF objFileItem.Name <> "Thumbs.db" and  objFileItem.Name <> "index.asp"  THEN 
            IF instr(1,objFileItem.Name,"_") <> 1 THEN 
                opt = opt & "<Option "
                  if objFileItem.Name = fileLink then opt = opt & " selected "
                opt = opt & ">" & objFileItem.Name & "</option>"
            end if
        end if
    Next    

    Set objFSO = Nothing
    Set objFile = Nothing
    Set objFolder = Nothing
    Set objFolderContents = Nothing
    Set objsubfol = Nothing

    opt_getPopUpsFolder = opt
End Function
thanks,
Sam

~~~~~~~~~~~~~~~~~~~~~~~
http://byldesigns.com
~~~~~~~~~~~~~~~~~~~~~~~
__________________
~~~~~~~~~~~~~~~~~~~~~~~
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://ebcpro.com.com
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;where EveryBusinessCounts
~~~~~~~~~~~~~~~~~~~~~~~
 
Old June 21st, 2004, 05:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Sam,

Take a look at this.

When I get a list of all files in a directory via the FileSystemObject, they aren't ordered in any reasonable way. How can I sort the files by name? Or by size? Or by date created? Or...

Hope that helps.
Cheers!

_________________________
-Vijay G
Strive for Perfection
 
Old June 21st, 2004, 09:51 AM
sam sam is offline
Authorized User
 
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

On the nose:).
Thanks,
Sam

~~~~~~~~~~~~~~~~~~~~~~~
http://byldesigns.com
~~~~~~~~~~~~~~~~~~~~~~~





Similar Threads
Thread Thread Starter Forum Replies Last Post
emptying contents of temp folder using vb wingers Visual Basic 2008 Essentials 1 June 27th, 2008 10:38 AM
I don't understand for some contents... jay0715 BOOK: Ivor Horton's Beginning Visual C++ 2005 0 November 4th, 2007 07:39 AM
Folder Contents DataSource amzar ASP.NET 1.x and 2.0 Application Design 0 September 28th, 2007 06:06 AM
App_Code folder shared on only 1 folder? rpeters83 ASP.NET 2.0 Professional 1 September 1st, 2006 10:53 PM
Making a folder virtual folder on button click in CsharpHelp C# 0 October 26th, 2005 05:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.