listing in order

This is a discussion on listing in order within the Windows Programming forums, part of the Platform Specific Boards category; Hello everyone; For my FTP program, when i display all the files and directories on the server i want the ...

  1. #1
    Registered User The15th's Avatar
    Join Date
    Aug 2001
    Posts
    125

    listing in order

    Hello everyone;

    For my FTP program, when i display all the files and directories on the server i want the directories to be displayed at the top, and the files to follow.

    while(InternetFindNextFile(hFindFile,&dwFlags)) {

    if( (dwFlags.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY ) {

    sprintf(DirName,"%s <DIR> ",dwFlags.cFileName);
    SendMessage (ServerFilesLST,LB_ADDSTRING, 0, (LPARAM)DirName);

    }
    else
    sprintf(FileName,"%s ",dwFlags.cFileName);
    SendMessage (ServerFilesLST,LB_ADDSTRING, 0, (LPARAM)FileName);
    }

    okay this displays the files, but doesnt put them into any order. I tried to first store the dwFlags.cFileName temporaly and write a \n sequence after it, but when i tried this my program just destroyed itself...

    this is what i tried.

    sprintf(t_DirName,"%s \n ",dwFlags.cFileName);
    strcat(DirName,t_DirName);

    and then i sent the DirName to the list box after the while loop was finished. But as i said, the program just exited... anyway i am quite stuck on this little problem of mine, so any help would be greatly appreciated. Thanks again.
    arrh, i got nothing good to say.
    http://www.praxis1.vic.edu.au/home/dcola/

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    How much space in DirName string?

    Is this going OOB (out of bounds) with the strcat()? (if in a loop, would be my bet)

    A way round it, though slow over the net would be to do the 'adding' twice the first loop for the DIR's the second for files.

    Else use some dynamic memory alloc. Keep the strings and if they are a DIR togather for later adding to the listbox, ie use an array of structures.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Laplace Expansion
    By Leojeen in forum C Programming
    Replies: 7
    Last Post: 10-28-2008, 11:26 PM
  2. Embedded SQL Order By
    By cjohnman in forum C Programming
    Replies: 12
    Last Post: 04-15-2008, 03:45 PM
  3. How do you order your game code?
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 02-05-2006, 05:26 PM
  4. Help with listing numbers in order
    By boontune in forum C++ Programming
    Replies: 2
    Last Post: 03-23-2003, 06:56 PM
  5. what is the significance of low order and high order bits
    By Shadow12345 in forum Windows Programming
    Replies: 1
    Last Post: 11-16-2002, 10:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21