I am using a browserdialog to browse to a folder that I know contains .txt files.
When pressing okay. I want all these .txt files to appear in my textFilesBox1.

I have come up with this code that do put the path directory in the textBox1.
I have searched for examples everywhere but cant figure out how to continue this code.
Would appreciate any starthelp

folderBrowserDialog1->ShowDialog();
       System::String ^ TextFiles= folderBrowserDialog1->SelectedPath; 
		
	System::IO::Directory::GetFiles(TextFiles,"*.txt");
		
	this->textFilesBox1->Text = TextFiles;

Using VC++ 2008 Express I created a CLI Windows project, added a multi-line text box control, then coded the below function. Note that this may or may not be the best way to do it, but it works. I selected *.sys files instead of *.txt, but all you have to do is change it however you want to.

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
        String^ namelist;
        array<String^>^  fileEntries = Directory::GetFiles("d:\\", "*.sys");
        IEnumerator^ files = fileEntries->GetEnumerator();
        while ( files->MoveNext() )
        {
            String^ fileName = safe_cast<String^>(files->Current);
            //ProcessFile( fileName );
            namelist += fileName + "\r\n";
        }
        this->textBox1->Text = namelist;
    }
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.