vector<wstring> to System::String ??</wstring>
-
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 guys... the program must make the filenames to be shown in the list ya in anyways, even its not in System::String as long its showed there is gud enough... i been working on this 3 days but nvr solved it..... :( 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 guys... the program must make the filenames to be shown in the list ya in anyways, even its not in System::String as long its showed there is gud enough... i been working on this 3 days but nvr solved it..... :( Regards, Thilek
Hi,
String::Format
requires the place holders ({0},{1}..) in the format string to work. You have usedString::Format
with an invalid format string. I can't see any need ofString::Format
here. As I understand, you need to add a newline character to the string. It can be done likelistBox1->Items->Add(String::Concat(someString,"\n"));
BTW, a list shows one item in a row. So why do you need to add line break? :)
Navaneeth How to use google | Ask smart questions
-
Hi,
String::Format
requires the place holders ({0},{1}..) in the format string to work. You have usedString::Format
with an invalid format string. I can't see any need ofString::Format
here. As I understand, you need to add a newline character to the string. It can be done likelistBox1->Items->Add(String::Concat(someString,"\n"));
BTW, a list shows one item in a row. So why do you need to add line break? :)
Navaneeth How to use google | Ask smart questions
-
really thanks a lot my fren. its really helped me. about the newlinew was a silly mistake done by me after sitting and breaking my head for 3 days to solve it... Thanks alot. God bless you. :-D
You are welcome. :)
Navaneeth How to use google | Ask smart questions