| | |
FindFirstFile()
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2008
Posts: 58
Reputation:
Solved Threads: 0
Hello everyone. I have attached a folderBrowserDialog1 to my Form1.
To a button I will do a function.
What I will do now is when I press the button, I want to open this folderBrowserDialog wich works fine.
After this I will click on a folder wich contains *.txt Files and press OK.
What will happen now is that all these .txt files names will appear in my textBox1.
I am trying this code out but really dont know what could be wrong.
I am trying to first FindFirstFile() but my compiler doesn´t compile.
What could be missing ?
Thanks
To a button I will do a function.
What I will do now is when I press the button, I want to open this folderBrowserDialog wich works fine.
After this I will click on a folder wich contains *.txt Files and press OK.
What will happen now is that all these .txt files names will appear in my textBox1.
I am trying this code out but really dont know what could be wrong.
I am trying to first FindFirstFile() but my compiler doesn´t compile.
What could be missing ?
C++ Syntax (Toggle Plain Text)
folderBrowserDialog1->ShowDialog(); HANDLE h; WIN32_FIND_DATA lpFileName; h = ::FindFirstFile(folderBrowserDialog1->SelectedPath, &lpFileName); this->textBox1->Text = h;
Last edited by Darth Vader; Feb 9th, 2008 at 6:48 pm.
1. The second parameter is not a filename, but a structure that contains a lot of fields including the filename. Look up FindFirstFile() in MSDN and you will see that that structure contains.
2. FindFirstFile returns a HANDLE. Setting
If you search the code snippets you will find a couple very extensive programs that use FindFirstFile() and FindNextFile().
2. FindFirstFile returns a HANDLE. Setting
this->textBox1->Text = h is just flat wrong. you should be setting it to the char array filename thats in the structure.If you search the code snippets you will find a couple very extensive programs that use FindFirstFile() and FindNextFile().
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Feb 2008
Posts: 58
Reputation:
Solved Threads: 0
If I begin with this code as I have closed out one line (//).
What will I need to make this compile. I beleive I am missing some basic things for this function to work:
Notice that I am Browsing a folder. Somthing is wrong with "&lpFileName" but from here I dont know how to continue.
Thank You...
I have looked around for examples but cant really get it right what is needed to do.
I found this code but are not sure if I should need something of this in my actual code.
So "&lpFileName" in my actual code is the same as "ffd" in this code. But nothing is done to "ffd" and will refer to it as I have done. So I am a bit lost here where to start.
I need to understand what this structure is that represents "&IpFileName" in my code.( This Line )
Link for whole code:
http://msdn2.microsoft.com/en-us/lib...00(VS.85).aspx
What will I need to make this compile. I beleive I am missing some basic things for this function to work:
Notice that I am Browsing a folder. Somthing is wrong with "&lpFileName" but from here I dont know how to continue.
C++ Syntax (Toggle Plain Text)
folderBrowserDialog1->ShowDialog(); HANDLE h; WIN32_FIND_DATA lpFileName; h = ::FindFirstFile(folderBrowserDialog1->SelectedPath, &lpFileName); // this->textBox1->Text = h;
Thank You...
I have looked around for examples but cant really get it right what is needed to do.
I found this code but are not sure if I should need something of this in my actual code.
So "&lpFileName" in my actual code is the same as "ffd" in this code. But nothing is done to "ffd" and will refer to it as I have done. So I am a bit lost here where to start.
I need to understand what this structure is that represents "&IpFileName" in my code.( This Line )
C++ Syntax (Toggle Plain Text)
h = ::FindFirstFile(folderBrowserDialog1->SelectedPath, &lpFileName);
C++ Syntax (Toggle Plain Text)
WIN32_FIND_DATA ffd; TCHAR szDir[MAX_PATH]; size_t length_of_arg; HANDLE hFind = INVALID_HANDLE_VALUE; DWORD dwError=0;
http://msdn2.microsoft.com/en-us/lib...00(VS.85).aspx
•
•
•
•
1. The second parameter is not a filename, but a structure that contains a lot of fields including the filename. Look up FindFirstFile() in MSDN and you will see that that structure contains.
2. FindFirstFile returns a HANDLE. Settingthis->textBox1->Text = his just flat wrong. you should be setting it to the char array filename thats in the structure.
If you search the code snippets you will find a couple very extensive programs that use FindFirstFile() and FindNextFile().
Last edited by Darth Vader; Feb 9th, 2008 at 8:12 pm.
![]() |
Similar Threads
- code for findfirstfile! (C)
- need FindFirstFile in linux!!!! (*nix Software)
- Win32_FIND_DATA FindFirstFile (C++)
- FindFirstFile & FindNextFile return extra files? (C++)
- Help with Searching files in Directories (C++)
- Visual c++ libraries (C++)
Other Threads in the C++ Forum
- Previous Thread: Templates (typedef VS class) ?
- Next Thread: Compile time errors in C++ while generating random numbers
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph homeworkhelp iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting spoonfeeding string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






