how to add the file names in a directory to a combobox
-
Hi, How can we add the file names in a directory to a combobox ? Thanks, Deepak Samuel
-
Hi, How can we add the file names in a directory to a combobox ? Thanks, Deepak Samuel
Use the
AddString()
method. If you are not using MFC, then send the control aCB_ADDSTRING
message.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Use the
AddString()
method. If you are not using MFC, then send the control aCB_ADDSTRING
message.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
If you want to get the files also you need to use
FindFirstFile()
andFindNextFile()
. A quick example of FindFirstFile straight from MSDN#define _WIN32_WINNT 0x0400 #include #include int main(int argc, char *argv[]) { WIN32_FIND_DATA FindFileData; HANDLE hFind; printf ("Target file is %s.\n", argv[1]); hFind = FindFirstFile(argv[1], &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { printf ("Invalid File Handle. GetLastError reports %d\n", GetLastError ()); return (0); } else { printf ("The first file found is %s\n", FindFileData.cFileName); FindClose(hFind); return (1); } }
Ant. -
If you want to get the files also you need to use
FindFirstFile()
andFindNextFile()
. A quick example of FindFirstFile straight from MSDN#define _WIN32_WINNT 0x0400 #include #include int main(int argc, char *argv[]) { WIN32_FIND_DATA FindFileData; HANDLE hFind; printf ("Target file is %s.\n", argv[1]); hFind = FindFirstFile(argv[1], &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { printf ("Invalid File Handle. GetLastError reports %d\n", GetLastError ()); return (0); } else { printf ("The first file found is %s\n", FindFileData.cFileName); FindClose(hFind); return (1); } }
Ant.Of course, but since the verb in the original post was "add", it only made sense that the combobox was the subject.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Of course, but since the verb in the original post was "add", it only made sense that the combobox was the subject.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
Sorry David my post was not meant as a critisism of yours. Since English is quite ambiguous I thought I would fill the possible missing part :) Ant.