For - help.

Hi people.

I have this bit of code:

1
2
3
4
String^ folder = "C:\\";
array<String^>^ file = Directory::GetFiles( folder );
for (int i=0; i<file->Length; i++)
textBox1->Text = file[i];


This displays the last filename (path included) in textBox1. However, I need to display all files. I feel as though it has something to do with 'for' line of code.

1. Can someone please point out what I need to do to display all files, not just the last?

2. How would I go about displaying just the filename rather than the pathname.

E.g I want:
textfile1.txt not c:\textfile1.txt

Thanks in advance.
Last edited on
Ok, I've answered the first question...

Line 4 needs to be replaced by:

textBox1->Text += file[i] + "\r\n"

Note: + "\r\n" just places the next file name on a separate line.

I'm sure there's other ways to do this so I'm still interested in hearing some advice.

Still need some help with question 2 if anyone is willing.

Cheers.
Last edited on
Topic archived. No new replies allowed.