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 ?

folderBrowserDialog1->ShowDialog();

HANDLE h;
WIN32_FIND_DATA lpFileName;
h = ::FindFirstFile(folderBrowserDialog1->SelectedPath, &lpFileName);

this->textBox1->Text = h;

Thanks

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 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().

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.

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 )

h = ::FindFirstFile(folderBrowserDialog1->SelectedPath, &lpFileName);
WIN32_FIND_DATA ffd;
TCHAR szDir[MAX_PATH];
size_t length_of_arg;
HANDLE hFind = INVALID_HANDLE_VALUE;
DWORD dwError=0;

Link for whole code:
http://msdn2.microsoft.com/en-us/library/aa365200(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. 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().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.