¿Cómo acceder al nombre del archivo desde la ubicación particular usando Listcontrol en MFC?

I am a beginner to Visual Studio C++. I am creating a dialog based application using MFC. I want to read some file and display some required text from that file in the dialog.

el código es:

   CFileFind finder;
    bool bFound;

   CString filename = "C:\\FilesLocation\\*.txt";

   bFound = finder.FindFile(filename);

   m_List.AddString(finder.GetFileName());  }

 in the last line,   error appears, whereas m_List is the member variable for List Control/

and Clistctrl has no member Addstring.

How to access the file name and display in the dialog ??

preguntado el 31 de julio de 12 a las 12:07

2 Respuestas

Depending on what exactly you're going to achieve, use CListCtrl::InsertItem vea la sección CListBox en lugar de CListCtrl. CListBox tiene AddString método.

Respondido 31 Jul 12, 14:07

i have already been doing ClistCtrl function. I cannot switch to Clistbox now. No knowledge about CListCtrl::InsertItem - Nabeel

@Nabeel: I provided the link to MSDN in my answer. - Andrey

Utilice las

  __in   LPCTSTR lpFileName,
  __out  LPWIN32_FIND_DATA lpFindFileData


pNombre de archivo [en] The directory or path, and the file name, which can include wildcard characters, for example, an asterisk (*) or a question mark (?).

lpFindFileData [out] A pointer to the WIN32_FIND_DATA structure that receives information about a found file or directory.

HANDLE hFind = FindFirstFile(path of the directory,&ffd);


Respondido 01 ago 12, 13:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.