This helper will do the trick:
public static class FileHelper { public static void MoveWithOverwrite(string sourceFileName, string targetFileName) { if (File.Exists(targetFileName)) { if ((File.GetAttributes(targetFileName) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) File.SetAttributes(targetFileName, FileAttributes.Normal); File.Delete(targetFileName); } File.Move(sourceFileName, targetFileName); } }
Copyright © 2003-2010 Falafel Software Inc.
The opinions expressed herein are Falafel's employees own personal opinions and do not represent Falafel Software's view in any way in case they go bananas!