CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2007
    Posts
    102

    boost filesystem exception problem

    Hi,

    I have one problem deleting a file with boost. The file is opened in another application and cannot be deleted.
    I am supposed to received an exception error but I don't get it. Any idea why?

    Here is my piece of code, very simple:
    Code:
    bool delete_file(const string &path) {
     
        boost::filesystem::path bpath(path);
        try {
            if (boost::filesystem::remove(bath)) return true;
            else return false;
        }
        catch (const boost::filesystem::filesystem_error &e) {
    
            return false;
    
        }
        return false;
    
    }
    I have put a breakpoint inside the catch part but it does not come to this point.
    Instead, the the output window of visual studio, I got these lines:

    First-chance exception at 0x00007FFD2E575A88 in site_server.exe: Microsoft C++ exception: boost::filesystem::filesystem_error at memory location 0x00000070F8E3E920.
    Unhandled exception at at 0x00007FFD2E575A88 in site_server.exe: Microsoft C++ exception: boost::filesystem::filesystem_error at memory location 0x00000070F8E3E920.

    I would appreciate if someone could explain me how to manage this situation?

    Thank you for reading,

    madric

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: boost filesystem exception problem

    I am supposed to received an exception error
    Yet you only assumed that the only exception thrown are ones that boost knows about.

    First, there is a difference between C++ exceptions, and the Microsoft OS structured exceptions. For example, access violations do not raise C++ exceptions, as those are SE's.

    http://stackoverflow.com/questions/3...ured-exception

    Try making sure that your application is compiled with SEH exceptions turned on, and have a catch all
    Code:
    catch(...)
    block afterwards.

    Regards,

    Paul McKenzie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured