CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: File list

  1. #1
    Join Date
    Jul 1999
    Posts
    535

    File list

    In my dialog app.. I want to list all the files in a single (predefined) directory... But I dont want to use a treeveiw...
    I want to use a list veiw so how can I get the names of all the files in the directory and how can I get a handle to each file in that directory?
    Any replies would be much appreciated... thanks...
    Cube


  2. #2
    Join Date
    May 1999
    Posts
    667

    Re: File list

    FindFirstFile/FindNextFile/FindClose

    note: be sure to call FindClose every time

    HTH,
    Chris


  3. #3
    Join Date
    Jul 1999
    Posts
    535

    Re: File list

    can you give me some sample code on how ta use it?
    I looked it up in the help but I'm not sure of the syntax... I'm just a beginner...


  4. #4
    Join Date
    May 1999
    Posts
    667

    Re: File list

    CString csFilePattern = "C:\TEMP\*.*"; // use your mask here
    WIN32_FIND_DATA findFileData;
    HANDLE hFindFileInfo;
    hFindFileInfo = FindFirstFile(csFilePattern, &findFileData);
    if (hFindFileInfo != INVALID_HANDLE_VALUE)
    {
    do
    {
    CString csFile = findFileData.cFileName; // The full name of file with ext not including path
    DeleteFile(csFile); // Do your file op here
    } while (FindNextFile(hFindFileInfo, &findFileData));
    FindClose(hFindFileInfo);
    }


    HTH,
    Chris


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

Featured