'Move with Replace' C# method
Join the DZone community and get the full member experience.
Join For FreeAs a workaround to that limitation, I wrote a simple, yet useful wrapper method below that allows for overwriting the destination file.
public static void MoveWithReplace(string sourceFileName, string destFileName) { //first, delete target file if exists, as File.Move() does not support overwrite if (File.Exists(destFileName)) { File.Delete(destFileName); } File.Move(sourceFileName, destFileName); }
Opinions expressed by DZone contributors are their own.
Comments