请帮帮我....
我想显示并返回我的一些文件的路径。
但不幸的是它没有返回所有文件的路径,
请看下面的照片
我的代码:
const std::filesystem::directory_options options = (
std::filesystem::directory_options::follow_directory_symlink |
std::filesystem::directory_options::skip_permission_denied
);
try
{
for (const auto& dirEntry :
std::filesystem::recursive_directory_iterator("C:\\",
std::filesystem::directory_options(options)))
{
std::cout << dirEntry.path().u8string() << std::endl;
}
}
catch (std::filesystem::filesystem_error & fse)
{
std::cout << fse.what() << std::endl;
}
错误:
状态: 该进程无法访问该文件,因为它正被另一个进程使用。例如: "C:\pagefile.sys"
问题是什么?
如何拒绝这个错误?
最佳答案
我是这样解决的:
if (!strstr(dirEntry.path().filename().u8string().c_str(), ".sys"))
{
std::cout << dirEntry.path().u8string() << std::endl;
}
关于c++ - cpp 进程无法访问该文件,因为它正被另一个进程使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59038530/