vector(wstring) to System::String ?
-
hi guys, i been working on a worm scanner lately... i got a funtion that list all the files in a directory.. but the the filename is on vector but i need to list them in a list box. but when i compile there is no problem but when i run it there is problem showing : An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll Additional information: Input string was not in a correct format. Below is my coding : if (ListFiles(directory, L"*", files)) { for (vector<wstring>::iterator it = files.begin(); it != files.end(); ++it) { std::string filename = WStringToString(it->c_str());; std::string s=filename; String ^someString= gcnew String(s.c_str()); listBox1->Items->Add(String::Format(someString,"\n")); // wcout << it->c_str() << endl; } } Kidly help me plz... Regards, Thilek
-
hi guys, i been working on a worm scanner lately... i got a funtion that list all the files in a directory.. but the the filename is on vector but i need to list them in a list box. but when i compile there is no problem but when i run it there is problem showing : An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll Additional information: Input string was not in a correct format. Below is my coding : if (ListFiles(directory, L"*", files)) { for (vector<wstring>::iterator it = files.begin(); it != files.end(); ++it) { std::string filename = WStringToString(it->c_str());; std::string s=filename; String ^someString= gcnew String(s.c_str()); listBox1->Items->Add(String::Format(someString,"\n")); // wcout << it->c_str() << endl; } } Kidly help me plz... Regards, Thilek
I suppose you don't need to convert the
std::wstring
to astd::string
before assigning it to aSystem.String
, moreover AFAIK the first argument toString::Format
should be the requested format. Anyway you'll eventually get better help in the(Managed) C++/CLI
[^] forum. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
I suppose you don't need to convert the
std::wstring
to astd::string
before assigning it to aSystem.String
, moreover AFAIK the first argument toString::Format
should be the requested format. Anyway you'll eventually get better help in the(Managed) C++/CLI
[^] forum. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
hi guys, i been working on a worm scanner lately... i got a funtion that list all the files in a directory.. but the the filename is on vector but i need to list them in a list box. but when i compile there is no problem but when i run it there is problem showing : An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll Additional information: Input string was not in a correct format. Below is my coding : if (ListFiles(directory, L"*", files)) { for (vector<wstring>::iterator it = files.begin(); it != files.end(); ++it) { std::string filename = WStringToString(it->c_str());; std::string s=filename; String ^someString= gcnew String(s.c_str()); listBox1->Items->Add(String::Format(someString,"\n")); // wcout << it->c_str() << endl; } } Kidly help me plz... Regards, Thilek
Thilek wrote:
i got a funtion that list all the files in a directory.. but the the filename is on vector but i need to list them in a list box.
Why can't you just send the listbox a
LB_DIR
message?"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch