所以我得到了这个错误:
类型为System::String ^
的参数与的参数不兼容 输入
LPCTSTR
当我尝试使用此代码时:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ currentDesktop = System::Environment::GetEnvironmentVariable("USERPROFILE") + "\\Desktop\\Test";
CreateDirectory (currentDesktop, NULL);
String^ value = (this->listBox1)->Text;
MessageBox::Show ("File has been created successfully. You've choosen: " + value, "Success", MessageBoxButtons::OK, MessageBoxIcon::Information);
}
};
所以我不确切知道问题出在哪里,所以请帮助我。
答案 0 :(得分:0)
谢谢你们,谢谢@Ben Voigt
此代码可以正常工作:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
String^ currentDesktop = System::Environment::GetEnvironmentVariable("USERPROFILE") + "\\Desktop\\Test";
msclr::interop::marshal_context context;
LPCTSTR desktop = context.marshal_as<LPCTSTR>(currentDesktop);
CreateDirectory (desktop, NULL);
String^ value = (this->listBox1)->Text;
MessageBox::Show ("File has been created successfully. You've choosen: " + value, "Success", MessageBoxButtons::OK, MessageBoxIcon::Information);
}
};