Click here to Skip to main content
15,888,816 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: urgrntly required Pin
CPallini9-Jan-09 2:11
mveCPallini9-Jan-09 2:11 
JokeRe: urgrntly required Pin
Jijo.Raj9-Jan-09 4:27
Jijo.Raj9-Jan-09 4:27 
QuestionNeed help to get list of files in a directory... Pin
Thilek9-Jan-09 0:50
Thilek9-Jan-09 0:50 
AnswerRe: Need help to get list of files in a directory... Pin
Hamid_RT9-Jan-09 0:54
Hamid_RT9-Jan-09 0:54 
AnswerRe: Need help to get list of files in a directory... Pin
Jijo.Raj9-Jan-09 0:58
Jijo.Raj9-Jan-09 0:58 
GeneralRe: Need help to get list of files in a directory... Pin
Thilek9-Jan-09 2:16
Thilek9-Jan-09 2:16 
GeneralRe: Need help to get list of files in a directory... Pin
David Crow9-Jan-09 3:15
David Crow9-Jan-09 3:15 
GeneralRe: Need help to get list of files in a directory... Pin
Thilek9-Jan-09 3:25
Thilek9-Jan-09 3:25 
NOW I CAN RUN IT USING VC++ PROFF 2005 NO PROBLEM Smile | :) ..

Below is the code i use :

1.#include <windows.h>
2.#include <stdio.h>
3.#include <iostream>
4.#include <string>
5.#include <sstream>
6.
7.
8.
9.std::string convertWCharArrayToString(const WCHAR * const wcharArray) {
10. std::stringstream ss;
11.
12. int i = 0;
13. char c = (char) wcharArray[i];
14. while(c != '\0') {
15. ss <<c;
16. i++;
17. c = (char) wcharArray[i];
18. }
19.
20. std::string convert = ss.str();
21. return convert;
22.}
23.
24.int main()
25.{
26. WIN32_FIND_DATA findFileData;
27. HANDLE hFind = FindFirstFile((LPCWSTR)"*", &findFileData);
28.
29. if(hFind == INVALID_HANDLE_VALUE) {
30. std::cout <<"No files found." <<std::endl;
31. } else {
32. std::cout <<"Files found." <<std::endl;
33. }
34.
35. int fileNumber = 0;
36. std::cout <<fileNumber <<":" <<convertWCharArrayToString(findFileData.cFileName) <<std::endl;
37. while(FindNextFile(hFind, &findFileData)) {
38. fileNumber++;
39. std::cout <<fileNumber <<":" <<convertWCharArrayToString(findFileData.cFileName) <<std::endl;
40. }
41.
42. FindClose(hFind);
43.
44. char a;
45. std::cin>> a;
46. return 0;
47.}



But when i change HANDLE hFind = FindFirstFile((LPCWSTR)"*", &amp;findFileData); to HANDLE hFind = FindFirstFile((LPCWSTR)"C:\*", &amp;findFileData);

its showing no file found and some funny symbols... but i wanted it to show entire list of files in a directory if i choose C:\ or D:\ and so on..


Can u guys help me plz... Smile | :)
GeneralRe: Need help to get list of files in a directory... Pin
David Crow9-Jan-09 3:28
David Crow9-Jan-09 3:28 
GeneralRe: Need help to get list of files in a directory... Pin
Thilek9-Jan-09 3:44
Thilek9-Jan-09 3:44 
QuestionRe: Need help to get list of files in a directory... Pin
David Crow9-Jan-09 3:47
David Crow9-Jan-09 3:47 
AnswerRe: Need help to get list of files in a directory... Pin
Thilek9-Jan-09 3:56
Thilek9-Jan-09 3:56 
GeneralRe: Need help to get list of files in a directory... Pin
David Crow9-Jan-09 4:06
David Crow9-Jan-09 4:06 
GeneralRe: Need help to get list of files in a directory... Pin
Thilek9-Jan-09 4:14
Thilek9-Jan-09 4:14 
GeneralRe: Need help to get list of files in a directory... Pin
David Crow9-Jan-09 4:18
David Crow9-Jan-09 4:18 
GeneralRe: Need help to get list of files in a directory... Pin
Thilek9-Jan-09 4:25
Thilek9-Jan-09 4:25 
GeneralRe: Need help to get list of files in a directory... Pin
David Crow9-Jan-09 4:28
David Crow9-Jan-09 4:28 
GeneralRe: Need help to get list of files in a directory... Pin
Thilek9-Jan-09 4:31
Thilek9-Jan-09 4:31 
AnswerRe: Need help to get list of files in a directory... Pin
vinvino20019-Jan-09 4:02
vinvino20019-Jan-09 4:02 
GeneralRe: Need help to get list of files in a directory... Pin
Thilek9-Jan-09 4:12
Thilek9-Jan-09 4:12 
GeneralRe: Need help to get list of files in a directory... Pin
Hamid_RT9-Jan-09 5:08
Hamid_RT9-Jan-09 5:08 
AnswerRe: Need help to get list of files in a directory... Pin
vinvino20019-Jan-09 6:18
vinvino20019-Jan-09 6:18 
QuestionIntercept all mouse event for a specified hwnd Pin
kcynic9-Jan-09 0:13
kcynic9-Jan-09 0:13 
AnswerRe: Intercept all mouse event for a specified hwnd Pin
Garth J Lancaster9-Jan-09 0:45
professionalGarth J Lancaster9-Jan-09 0:45 
GeneralRe: Intercept all mouse event for a specified hwnd Pin
kcynic9-Jan-09 1:10
kcynic9-Jan-09 1:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.