Thread: listing in order

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

    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)) {


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

    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);

    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.

  2. #2
    train spotter
    Join Date
    Aug 2001
    near a computer
    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
    Replies: 15
    Last Post: 02-05-2006, 06:26 PM
  4. Help with listing numbers in order
    By boontune in forum C++ Programming
    Replies: 2
    Last Post: 03-23-2003, 07: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, 11:46 AM