lundi 13 avril 2015

Opening a network file using CreateFile fails with FILE_NOT_FOUND

So I'm trying to simulate a distant file opening, which is pointing back to my computer, however i keep failing with error 3 (FILE_NOT_FOUND). I went through the following documentation regarding network usage, but it didn't work either.



hFile1 = ::CreateFile(LR"(\\172.17.12.172\C$\Develop\Code\File.txt)", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (INVALID_HANDLE_VALUE == hFile1)
{
LOG_ERROR(L"Failed opening file with: " << GetLastError());
break;
}



  1. The FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE flags are for the GetFileInformationByHandle which is used later on, i compare file paths.

  2. I tried opening \\172.17.12.172\C$\Develop\Code\File.txt using notepad, it worked.


172.17.12.172 is my local ip address.


Aucun commentaire:

Enregistrer un commentaire