如何在 C++/CLI 中递归搜索目录
谷歌搜索递归搜索的 Windows 示例,我发现 this 但尝试使用 cl 编译它(并且MSVC++ 工具链)编译器会指出错误之上的错误。当我不使用 MSVC++ GUI 完成的常规设置时,是否需要直接包含一些额外的库?
发布的示例错误代码已翻译,因此可能与英文版本不完全一样。
"*": This referencing cannot be done for System::String the compiler substitutes "*" by
"^" to continue analysis
这
System::String ^ a system-owned array cannot contain this managed type
两个错误都在这一行
String* directories[] = Directory::GetDirectories(dir.c_str()); //dir is a usual string
,因此不是我的编码。
我搞砸了什么?
编译行是:
cl /w /c /clr file.cpp
Googling for an windows example of a recursive search i found this but trying to compile this with cl (and the MSVC++ tool chain) the compiler states error over error. Do I need to include some extra libraries directly as soon as i am not using the usual setup done by the MSVC++ GUI.
The posted example error codes are translated and therefore might not look exactly like they would in English.
"*": This referencing cannot be done for System::String the compiler substitutes "*" by
"^" to continue analysis
and
System::String ^ a system-owned array cannot contain this managed type
both those errors are on this line
String* directories[] = Directory::GetDirectories(dir.c_str()); //dir is a usual string
and therefore are not my coding.
What am I messing up?
The compile-line was:
cl /w /c /clr file.cpp
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Directory::GetDeictories 是一个 .net 调用,因此它将返回一个 .net 对象。您正在尝试将其转换为 C++ 指针。最好的选择是声明一个 .net 字符串数组。类型就像这样
Directory::GetDeirectories is a .net call so it will return a .net object. You are trying to cast it to a c++ pointer. Your best bet is to declare a .net string array instead. The type is like so