Oh, sorry, my fault. But in that case you are trying to do smth very strange :)
Take a look at the signature of path::filename. It returns a copy of the filename part. You just assign a new value to the temporary string. And than your app tries to delete the executable itself, which is locked by the running process. That's why you get an error.
Your intention probably was:
path.remove_filename() /= L"compilation date.txt";
if (boost::filesystem::exists(path))
boost::filesystem::remove(path);
//should workRegards,
Ovanes