ERROR_BAD_NETPATH persists until application is restarted RRS feed

  • Question

  • Hi all,

    I have a simple application that periodically goes looking for a file on a network share. The file name is variable, but it follows a pattern, which I can handily find with a CFileFind object. To this object, I pass a string of the form "\\<server address>\<folder>\<file pattern>". The folder is accessible to the user running the program.

    This works nicely, with a notable exception. At this location, the network is unreliable and sometimes goes down for a few minutes. I know this, so my program is supposed to give up on the operation if a problem occurs, and try again later. This should work in theory.

    In practice, though, when the net goes down, I get an error 53 (ERROR_BAD_NETPATH) - and I keep getting it on every subsequent attempt to access the server, even if the network goes back up in the mean time. Sure enough, restarting the application fixes the problem, so the network is definitely up.

    I don't know why this would be the case. As near as I can tell, there are no handles or objects that I carry on from one attempt to the next. The CFileFind is reinstantiated every time. I don't see why restarting the application should work and creating a new CFileFind doesn't.

    Anyone has any suggestions?

    • Moved by Jesse Jiang Friday, October 14, 2011 5:27 AM (From:Visual C++ General)
    Thursday, October 13, 2011 4:25 PM

All replies

  • Hello,


    I think your issue should be raised in the General Windows Desktop Development Issues. I believe they will know more information of this issue than us, and I will move this one to that forum.


    Thanks for your understanding,


    Best regards,


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, October 14, 2011 5:27 AM
  • I'm having exactly the same problem but using WNetAddConnection2()

    Sometimes I'm getting error 53 even for just a wrong password and the error is "recoverable" on the next try,

    but if the network is somehow unreliable I can get an error 53 (ERROR_BAD_NETPATH) (with valid username/password) but this time the error is not recoverable (only app restart fixes the thing).

    I'd appreciate some help on this topic.

    Tuesday, September 25, 2012 8:30 AM
  • I couldn't find a solution. In the end, I arranged things so that the application detects the problem when it occurs, at which point it spawns a new copy of itself and then dies. Information is passed from the old instance to the new, so that the new instance knows it has to retry the operation that failed. It's a non-interactive program, so restarting is not a big deal. I'm just annoyed at having to recourse to such an ugly hack.
    Wednesday, October 3, 2012 8:49 AM