Solved

Getting file and directory names in a directory.

Posted on 2003-11-11
3
444 Views
Last Modified: 2010-04-01
hi;
i want to get the directory and file names in a directory. And adding them into a pop-up menu
i want to create a start-up menu like windows'. thanks for your help.
0
Comment
Question by:kenanerdey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 9720904
See FindFirstFile, FindNextFile, FindClose.
0
 

Author Comment

by:kenanerdey
ID: 9721606
i now but, how will i know what i found is file or directory ? how will i construct the loop ?
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 total points
ID: 9721703
   WIN32_FIND_DATA find_data;
    CString sSearchString = _T("C:\\SomeDirectory\\*.*");  // set here your search string
   
    HANDLE hFindFileHandle = FindFirstFile(
        sSearchString,
        &find_data);
   
   
    if ( hFindFileHandle == INVALID_HANDLE_VALUE )
    {
        return;
    }
   
    while ( TRUE )
    {
        if ( ! (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )   // not directory
        {
            // Handle file here. It's name (without path) is in find_data.cFileName
        }
       
        // next file
        if ( ! FindNextFile(hFindFileHandle, &find_data) )
            break;
    }
   
    FindClose(hFindFileHandle);
   
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
White board coding practice 3 98
Embarcadero WebBroker REST server endpoint parameters 2 115
Gaming Software 1 38
Need some help with design 17 46
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question