Click to See Complete Forum and Search --> : String Conversion..


somu0915
February 27th, 2008, 07:36 AM
How to convert from System::String^ to System::String ?

Here is the code where I am facing the error:



for(int i =0 ; i < tempDir->Length; i++)
{
array<String^>^ tempFile = Directory::GetFiles(tempDir[i]);
objListBox->Items->Add(System::String(tempFile[i]).ToString());
}

GCDEF
February 27th, 2008, 07:56 AM
Wrong forum.

MrViggy
February 27th, 2008, 02:35 PM
How to convert from System::String^ to System::String ?

Here is the code where I am facing the error:



for(int i =0 ; i < tempDir->Length; i++)
{
array<String^>^ tempFile = Directory::GetFiles(tempDir[i]);
objListBox->Items->Add(System::String(tempFile[i]).ToString());
}
No idea. That's C#, not C++.

Viggy

Siddhartha
February 27th, 2008, 03:06 PM
[ redirected to MC++ Forum ]

Regards,
Siddhartha

darwen
February 27th, 2008, 03:44 PM
Short answer, you can't.

Shorter answer : you don't need to.


objListBox->Items->AddRange(tempFile);


Or if that doesn't work (assuming temp dir is a .NET array)


for each (System::String ^directory in tempDir)
{
array<String^>^ tempFile = Directory::GetFiles(directory);

for each (String ^file in tempFile)
{
objListBox->Items->Add(file);
}
}


Notice the use of 'for each'.

Darwen.

somu0915
February 27th, 2008, 10:57 PM
Short answer, you can't.

Shorter answer : you don't need to.


objListBox->Items->AddRange(tempFile);


Or if that doesn't work (assuming temp dir is a .NET array)


for each (System::String ^directory in tempDir)
{
array<String^>^ tempFile = Directory::GetFiles(directory);

for each (String ^file in tempFile)
{
objListBox->Items->Add(file);
}
}


Notice the use of 'for each'.

Darwen.



Hey Darwen,
Thanks for the exact reply..
But a quick question for you..
As you might have got it, I am trying to search for all the files in the file system, and naturally I am using recursion for this..

And its catching my nerves because its really too slow..
It hangs too..

Any idea how I can optimize it??
Can I apawn threads for every directory it finds..??
Will that make it faster??
And if yes, can u guide me (write some sample code), how to go about doing it??

Thanx..