0

I found a problem in different c++ function/way to try if a file exist.

Scenario :

A timer test if a file exist over a UNC path every x seconds.

It works fine.

I lost the network.

Program hangs during a while...

Network is reconnected and now every time i try if the file exist the program hangs.

The code :

The hang after the reconnection happen with :

WIN32_FIND_DATA FindFileData;
if(INVALID_HANDLE_VALUE == FindFirstFile(onlineFile, &FindFileData))

And with :

DWORD dwAttrib = GetFileAttributes(FileName.c_bstr());
return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
     !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));

For me it is a very basicall function but it hang on 5 computers. (Win 7).

Is there a special function to test access to file over network ?

Thanks.

Maypeur
  • 387
  • 4
  • 18
  • Firstly, you have to check if the UNC path is available. Then you can test if your file exist. Take a look at [this](http://stackoverflow.com/questions/5152647/how-to-quickly-check-if-unc-path-is-available) – Atnaize May 13 '15 at 07:21
  • Ok thanks, but my problem isn't when the program freeze during the lost of network. My problem is that every function i try after the network reconnection hangs. – Maypeur May 13 '15 at 07:30

0 Answers0