2014-11-03 4 views
0

Windows 양식 응용 프로그램 그림 상자 메서드로드를 사용하려고합니다. 나는 다음과 같은 오류를 얻고있다, 그러나매개 변수 1을 basic_string에서 String으로 변환 할 수 없습니다.^

  string image = "image.jpg"; 
      pictureBox2->Size = System::Drawing::Size(36, 40); 
      pictureBox2->Load(image); 
      Controls->Add(pictureBox2); 

: 이렇게하려면 내 코드는 다음과

'void System::Windows::Forms::PictureBox::Load(System::String ^)' : cannot convert parameter 1 from 'std::basic_string<_Elem,_Traits,_Ax>' to 'System::String ^' 

내가^문자열로 문자열을 변환 할 수있는 방법 어떤 생각? 단순히

답변

1

이 그것을 수행해야합니다

std::string image("image.png"); 
String^ MyString = gcnew String(image.c_str()); 
2

사용 :

String ^image = "image.png"; 

Load 관리되는 문자열을 기다립니다.

+0

이미지 이름은 exmaple이었다. 나는 dirent.h를 사용하여 dir에서 파일을로드하고 벡터에 저장합니다. . 벡터로 변경하는 변경 사항이 있습니까? –

관련 문제