Search code examples
c++fileresourceslockinghandle

EndUpdateResource() throws Error 110 The system cannot open the device or file specified when windowsexplorer is open at the output location


The following code throws a 110 Error on the EndUpdateResource call only when windows explorer is open at D:\test\output\ where the executable is being copied to:

std::ifstream in("C:\\Windows\\notepad.exe", std::ios::binary);
std::ofstream out("D:\\test\\output\\notepad.exe", std::ios::binary);
out << in.rdbuf();
in.close();
out.close();

Handle hUpdateRes = BeginUpdateResource(_T("D:\\test\\output\\notepad.exe"), FALSE);
EndUpdateResource(hUpdateRes, FALSE);

As long as I don't have that folder open in windows explorer it works fine. If I have it open it will throw an error. Also, if I do a CreateFile with read and write access before the BeginUpdateResource call it will work fine even if I have the output folder open. I am really confused and would appreciate any help. Thanks!


Solution

  • I disabled the on demand virus scanner on the machine and the code no longer throws an error.