## Jennifer84

This code(Files) does return the whole directorypath like this:

C:\Documents and Settings\User\Desktop\Text.txt

What should be changed if you only want to return the fileName wich is: "Text"

Code:
System::string ^ Files10 = "c:\\";

array<System::string ^> ^ Files = System::IO:: Directory::GetFiles(Files10,"*.txt");

## Ancient Dragon 5,243

You need to start reading the descriptions for the System::String methods in msdn so that you can learn how to look up the method(s) you need to solve your problems. What you need is a method that will locate (or find) the last '\\' in the string then another method that will take the substring of all the rest of the characters.

## DangerDev 107

after getting all the filename along with path u need to use String object's (search pattern to get) subString method to get file name.

## Jennifer84

Thank you for this tips. I really want and am trying to read and understand msdn examples as it is very good.
I have used Substring() wich is okay for me here. I have managed to take all directory away to I only have Text.txt left in:

"c:\\abc\\def\\Text.txt

What I am trying is to take .txt away and from what I understand from msdn I will "Split" this like I have tried in the code. The code compiles but the program wont start.

My thinkingsteps from this code is that first files4 is splitted so .txt dissapear, then converted to a String() and then Substring it with the remaining.
Where am I thinking wrong here. ?

array<Char>^ chars = {'.'};
comboBox1->Items->Add(files4[count]->Split(chars)->ToString()->Substring(14));
System::String ^ Files10 = "c:\\abc\\def\\";

array<System::String ^> ^ files4 = System::IO::Directory::GetFiles(Files10,"*.txt");

array<Char>^ chars = {'.'};

for( int count = 0; count < files4->Length; count++)

{

}

after getting all the filename along with path u need to use String object's (search pattern to get) subString method to get file name.

## Jennifer84

I did solve this with a for loop and this works great. So the solution is seen in the code below:

array<Char>^ chars = {'.'};
array<System::String ^> ^ splits;

for (int count1 = 0; count1 < files4->Length; count1++)
{
splits = files4[count1]->Split(chars);

IEnumerator^ myEnum = splits->GetEnumerator();

}