public bool Move(FileInfo path, Func <bool> replace) { var oldFile = File; if (path.Exists) { if (replace()) { path.Delete(); } else { return(false); } } var stream = m_upToDateFile.Migrate(); m_upToDateFile.Dispose(); System.IO.File.Move(oldFile.FullName, path.FullName); m_upToDateFile = new UpToDateFile(stream, path, s => { }); m_upToDateFile.FileChanged += () => FileModifiedExternally.Execute(); m_upToDateFile.FileDeleted += () => FileDeletedExternally.Execute(); Moved.Execute(oldFile, File); return(true); }
public void GotMoved(FileInfo newPath) { var oldFile = File; File = newPath; Moved.Execute(new Changed <FileInfo>(oldFile, File)); }
public void GotMoved(FileInfo newPath) { var oldFile = File; File = newPath; Moved.Execute(oldFile, File); }
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); }
public void Move(FileInfo path, Func <bool> replace) { var oldFile = File; if (path.Exists) { if (replace()) { path.Delete(); } else { return; } } FileStream newFile = path.Open(FileMode.CreateNew, FileAccess.ReadWrite); m_file.Position = 0; m_file.CopyTo(newFile); newFile.Flush(); m_file.Close(); File.Delete(); m_file = newFile; Moved.Execute(oldFile, File); }
public void GotMoved(FileInfo newPath) { var oldFile = File; m_upToDateFile = new UpToDateFile(m_upToDateFile.Migrate(), newPath, s => { }); m_upToDateFile.FileChanged += () => FileModifiedExternally.Execute(); m_upToDateFile.FileDeleted += () => FileDeletedExternally.Execute(); Moved.Execute(oldFile, File); }
public void GotMoved(FileInfo newPath) { var oldFile = File; m_upToDateFile = new UpToDateFile(m_upToDateFile.Migrate(), newPath, m_saveTo, m_backEnd); m_upToDateFile.FileChanged += () => FileModifiedExternally.Execute(); m_upToDateFile.FileDeleted += () => FileDeletedExternally.Execute(); Moved.Execute(new Changed <FileInfo>(oldFile, File)); }
public void SaveAs(FileInfo path) { var oldPath = File; m_upToDateFile.Dispose(); m_upToDateFile = new UpToDateFile(new MemoryStream(), path, m_saveTo); m_upToDateFile.FileChanged += () => FileModifiedExternally.Execute(); m_upToDateFile.FileDeleted += () => FileDeletedExternally.Execute(); Save(); Moved.Execute(oldPath, File); }
public void SaveAs(FileInfo path) { var oldPath = File; m_upToDateFile.Dispose(); using (MemoryStream m = new MemoryStream()) { m_upToDateFile = new UpToDateFile(m, path, m_saveTo, m_backEnd); } m_upToDateFile.FileChanged += () => FileModifiedExternally.Execute(); m_upToDateFile.FileDeleted += () => FileDeletedExternally.Execute(); Save(); Moved.Execute(new Changed <FileInfo>(oldPath, File)); }
public bool Move(string newPath, Func <bool> replace) { Func <DirectoryInfo, bool> moveFolder = a => { if (!Directory.Exists(newPath)) { var oldpath = a.FullName; a.MoveTo(newPath); Moved.Execute(oldpath, newPath); return(true); } else { MessageBox.Show("A directory already exists at this location"); return(false); } }; return(m_target.Transformed(moveFolder, b => b.Move(new FileInfo(newPath), replace))); }
public bool Move(FileInfo path, Func <bool> replace) { var oldFile = File; if (path.Exists) { if (replace()) { path.Delete(); } else { return(false); } } System.IO.File.Move(oldFile.FullName, path.FullName); File = path; Moved.Execute(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); } } System.IO.File.Move(oldFile.FullName, newPath.FullName); File = newPath; Moved.Execute(new Changed <FileInfo>(oldFile, File)); return(true); }