使用boost库删除文件夹时出现问题 [英] Problem in deleting a folder using boost library
问题描述
先生,我正在使用boost库进行各种文件处理。我在使用boost库删除文件夹时遇到问题。
我用过它,
#include < boost \filesystem \operations。 hpp > //作为头文件
boost :: filesystem :: path fOne = c:\\A; // 在主代码中
boost :: filesystem :: remove_all(fOne);
这适用于多个地点(例如在C:\\ A)
但是当我试试这个时位置C:\\Windows \\A可执行文件成功构建,零错误和零警告。然后,当我尝试执行按钮上执行的功能时,单击一个消息框打开,如此
未处理的异常在0x75CBD8A8在HelpProject.exe:微软C ++异常:升压::文件系统:: filesystem_error内存位置0x0018EF68
我发现这是一个错误如何解决这类错误?
我在调试代码方面有一些知识,但不知道生成的可执行文件。所以我关闭了visual studio并打开了可执行文件,并尝试执行函数
并且它显示我这样,
调试错误中止()已经调用了!
我尝试在管理员模式下打开可执行文件但没有用
Am我错过了什么?
我应该添加更多信息吗?
谢谢
请阅读 remove_all()的文档[ ^ ]:
Quote:抛出:如错误报告中所述。
Quote:
当执行程序调用操作系统或其他底层操作时API导致错误导致函数无法满足其规范,抛出类型filesystem_error的例外。
因此您必须捕获并处理异常。阅读一些关于C ++异常的教程和 Boost Filesystem exception.hpp Header [ ^ ]。
Sir, I am using boost libraries for various file handling purposes. I have a problem in deleting a folder using boost libraries.
I used this,
#include<boost\filesystem\operations.hpp>// as a header file
boost::filesystem::path fOne = "c:\\A";// in main code
boost::filesystem::remove_all(fOne);
This works for the several locations(for e.g in C:\\A)
But when I try this location C:\\Windows\\A the executable builds successfully with zero error and zero warning.Then when I tried to execute the function which executes on button click a message box opens like this
Unhandled exception at 0x75CBD8A8 in HelpProject.exe: Microsoft C++ exception: boost::filesystem::filesystem_error at memory location 0x0018EF68.
I found this was an error message how can I solve this type of errors?
I have some knowledge in debugging the code but not the generated executable. So I closed the visual studio and opened the executable and tried to execute the function
and it shows me like this,
Debug error abort() has called!
I tried by opening the executable in administrator mode but no use
Am I missing anything?
Should I add still more information?
Thank you
Just read the documentation for remove_all()[^]:
Quote:Throws: As specified in Error reporting.
Follow the link there to Error-reporting[^]:
Quote:
When a call by the implementation to an operating system or other underlying API results in an error that prevents the function from meeting its specifications, an exception of type filesystem_error is thrown.
So you have to catch and handle the exception. Read some tutorial about C++ exceptions and Boost Filesystem exception.hpp Header[^].
这篇关于使用boost库删除文件夹时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!