【发布时间】:2013-03-01 22:59:43
【问题描述】:
我有以下函数,希望能告诉我文件夹是否存在,但是当我调用它时,我得到了这个错误 -
无法将参数 1 从 'System::String ^' 转换为 'std::string'
函数-
#include <sys/stat.h>
#include <string>
bool directory_exists(std::string path){
struct stat fileinfo;
return !stat(path.c_str(), &fileinfo);
}
调用(来自包含用户选择文件夹的表单的 form.h 文件)-
private:
System::Void radioListFiles_CheckedChanged(System::Object^ sender, System::EventArgs^ e) {
if(directory_exists(txtActionFolder->Text)){
this->btnFinish->Enabled = true;
}
}
有人能告诉我如何解决这个问题吗?谢谢。
【问题讨论】:
-
我从没想过会看到有人在同一个调用中使用 C++/CLI、STL 和 POSIX 函数...
-
@Matteo : 是的,这太可恶了...
-
这几乎就像我对 C++ 不太熟悉,因此需要寻求帮助!我很感激你可能笑了,但请可怜我吧!