Click here to Skip to main content
14,733,966 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
nv3 31-Jan-16 9:45am
   
Obviously that has to do with the special protection of the \Windows directory, which probably hosts your operating system. My guess is that the code in remove_all is not handling some return code correctly and then crashes. I would compile in debug mode and step inside the remove_all function to see what it's doing.
[no name] 1-Feb-16 9:51am
   
Thank you sir for your kind help

1 solution

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[^].
   
Comments
[no name] 1-Feb-16 9:49am
   
Thank you sir for your kind help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900