Directory listing

Discussion in 'C++' started by David White, Dec 23, 2003.

  1. David White

    David White Guest

    "Andreas Iwanowski" <> wrote in message
    news:bsab2o$vv0$...
    > Hello.
    > Is there a function in the Win32 API that returns a list of

    files/subfolders
    > in a specific folder ?


    Off-topic. Try a Windows programming newsgroup.

    DW
     
    David White, Dec 23, 2003
    #1
    1. Advertising

  2. David White

    Alad Guest

    // FROM MSDN LIBRARYWIN32_FIND_DATA FileData;
    HANDLE hSearch;
    DWORD dwAttrs;
    char szDirPath[] = "c:\\TEXTRO\\";
    char szNewPath[MAX_PATH];
    char szHome[MAX_PATH];

    BOOL fFinished = FALSE;

    // Create a new directory.

    if (!CreateDirectory(szDirPath, NULL))
    {
    ErrorHandler("Couldn't create new directory.");
    }

    // Start searching for .TXT files in the current directory.

    hSearch = FindFirstFile("*.txt", &FileData);
    if (hSearch == INVALID_HANDLE_VALUE)
    {
    ErrorHandler("No .TXT files found.");
    }

    // Copy each .TXT file to the new directory
    // and change it to read only, if not already.

    while (!fFinished)
    {
    lstrcpy(szNewPath, szDirPath);
    lstrcat(szNewPath, FileData.cFileName);
    if (CopyFile(FileData.cFileName, szNewPath, FALSE))
    {
    dwAttrs = GetFileAttributes(FileData.cFileName);
    if (!(dwAttrs & FILE_ATTRIBUTE_READONLY))
    {
    SetFileAttributes(szNewPath,
    dwAttrs | FILE_ATTRIBUTE_READONLY);
    }
    }
    else
    {
    ErrorHandler("Couldn't copy file.");
    }

    if (!FindNextFile(hSearch, &FileData))
    {
    if (GetLastError() == ERROR_NO_MORE_FILES)
    {
    MessageBox(hwnd, "No more .TXT files.",
    "Search completed.", MB_OK);
    fFinished = TRUE;
    }
    else
    {
    ErrorHandler("Couldn't find next file.");
    }
    }
    }

    // Close the search handle.

    if (!FindClose(hSearch))
    {
    ErrorHandler("Couldn't close search handle.");
    } "Andreas Iwanowski" <> дÈëÓʼþ
    news:bsab2o$vv0$...
    > Hello.
    > Is there a function in the Win32 API that returns a list of

    files/subfolders
    > in a specific folder ?
    >
    >
    >
     
    Alad, Dec 24, 2003
    #2
    1. Advertising

  3. Hello.
    Is there a function in the Win32 API that returns a list of files/subfolders
    in a specific folder ?
     
    Andreas Iwanowski, Dec 24, 2003
    #3
  4. David White

    Jack Klein Guest

    On Wed, 24 Dec 2003 09:32:59 +0800, "Alad" <> wrote
    in comp.lang.c++:

    > // FROM MSDN LIBRARYWIN32_FIND_DATA FileData;
    > HANDLE hSearch;
    > DWORD dwAttrs;
    > char szDirPath[] = "c:\\TEXTRO\\";
    > char szNewPath[MAX_PATH];
    > char szHome[MAX_PATH];
    >
    > BOOL fFinished = FALSE;


    ....and in what section of the ISO C++ International Standard is this
    defined?

    Kindly do not vandalize comp.lang.c++ with off-topic replies to
    off-topic posts. The Windows API is most specifically off-topic here.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c /faq
     
    Jack Klein, Dec 24, 2003
    #4
  5. David White

    Alad Guest

    Thank you for your caution. It is the first time I post some notes to this
    news group, and I won't make the same mistake next time.

    "Jack Klein" <> ????
    news:...
    > On Wed, 24 Dec 2003 09:32:59 +0800, "Alad" <> wrote
    > in comp.lang.c++:
    >
    > > // FROM MSDN LIBRARYWIN32_FIND_DATA FileData;
    > > HANDLE hSearch;
    > > DWORD dwAttrs;
    > > char szDirPath[] = "c:\\TEXTRO\\";
    > > char szNewPath[MAX_PATH];
    > > char szHome[MAX_PATH];
    > >
    > > BOOL fFinished = FALSE;

    >
    > ...and in what section of the ISO C++ International Standard is this
    > defined?
    >
    > Kindly do not vandalize comp.lang.c++ with off-topic replies to
    > off-topic posts. The Windows API is most specifically off-topic here.
    >
    > --
    > Jack Klein
    > Home: http://JK-Technology.Com
    > FAQs for
    > comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    > comp.lang.c++ http://www.parashift.com/c -faq-lite/
    > alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c /faq
     
    Alad, Dec 25, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JD

    Directory Listing

    JD, Aug 24, 2003, in forum: Perl
    Replies:
    0
    Views:
    1,134
  2. Todd Lu

    Directory listing

    Todd Lu, Aug 31, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    462
    Todd Lu
    Aug 31, 2004
  3. =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=

    directory listing details

    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=, May 24, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    407
    =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?=
    May 24, 2005
  4. Tim_Mac
    Replies:
    2
    Views:
    368
    Tim_Mac
    Dec 15, 2005
  5. Light
    Replies:
    1
    Views:
    947
    Eliyahu Goldin
    Mar 22, 2006
Loading...

Share This Page