Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. vector<wstring> to System::String ??</wstring>

vector<wstring> to System::String ??</wstring>

Scheduled Pinned Locked Moved Managed C++/CLI
helpgraphicsquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thilek
    wrote on last edited by
    #1

    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

    N 1 Reply Last reply
    0
    • T 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

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Hi, String::Format requires the place holders ({0},{1}..) in the format string to work. You have used String::Format with an invalid format string. I can't see any need of String::Format here. As I understand, you need to add a newline character to the string. It can be done like

      listBox1->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

      T 1 Reply Last reply
      0
      • N N a v a n e e t h

        Hi, String::Format requires the place holders ({0},{1}..) in the format string to work. You have used String::Format with an invalid format string. I can't see any need of String::Format here. As I understand, you need to add a newline character to the string. It can be done like

        listBox1->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

        T Offline
        T Offline
        Thilek
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • T Thilek

          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

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          You are welcome. :)

          Navaneeth How to use google | Ask smart questions

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups