using (var f = File.Open(oldName, FileMode.Open, FileAccess.Read, FileShare.Delete)) { Kernel32.MoveFileEx(oldName, newName, 0); }