public bool Move(FileInfo newPath, Func <bool> replace) { var oldFile = File; if (newPath.Exists) { if (replace()) { newPath.Delete(); } else { return(false); } } var stream = m_upToDateFile.Migrate(); m_upToDateFile.Dispose(); System.IO.File.Move(oldFile.FullName, newPath.FullName); m_upToDateFile = new UpToDateFile(stream, newPath, s => { }, m_backEnd); m_upToDateFile.FileChanged += () => FileModifiedExternally.Execute(); m_upToDateFile.FileDeleted += () => FileDeletedExternally.Execute(); Moved.Execute(new Changed <FileInfo>(oldFile, File)); return(true); }
public bool Move(FileInfo newPath, Func <bool> replace) { var oldFile = File; if (newPath.Exists) { if (replace()) { newPath.Delete(); } else { return(false); } } var stream = m_upToDateFile.Migrate(); newPath.Directory.EnsureExists(); //This can fail (returning false) if it does then we subsequently get a (hopefully) useful exception from File.Move System.IO.File.Move(File.FullName, newPath.FullName); m_upToDateFile.Dispose(); m_upToDateFile = new UpToDateFile(stream, newPath, m_saveTo, m_backEnd); m_upToDateFile.FileChanged += () => FileModifiedExternally.Execute(); m_upToDateFile.FileDeleted += () => FileDeletedExternally.Execute(); Moved.Execute(new Changed <FileInfo>(oldFile, File)); return(true); }