The TlmRecorder::openDB(const std::string& dbName) function does create the ifstream object with the file name: std::ifstream f(dbName.c_str()); Then check if the file exists with if (f.good()). So far so good however remove(dbName.c_str()) always fails to delete the file under Windows. It seems internally Windows does open the file when f.good() is called. Then the remove call will fail with a shared violation status. To fix the issue f.close() must be called before the remove call.