public void CopyFile(IFile file, bool synchronous) { var copy_options = 4 | 16 | 512 | 1024; var andoid = file as PortableFile; var win = file as WinFile; // it can either be android or windows Debug.Assert(andoid != null || win != null); FolderItem dest_item = null; var souce_name = file.Name; if (andoid != null) { dest_item = andoid.RawFolderItem(); } else if (win != null) { var WinFile_name = new FileInfo(win.FullPath); var shell_folder = WinUtil.GetShell32Folder(WinFile_name.DirectoryName); var shell_file = shell_folder.ParseName(WinFile_name.Name); Debug.Assert(shell_file != null); dest_item = shell_file; } // Windows stupidity - if file exists, it will display a stupid "Do you want to replace" dialog, // even if we speicifically told it not to (via the copy options) // // so, if file exists, delete it first var existing_name = (fi_.GetFolder as Folder).ParseName(souce_name); if (existing_name != null) { WinUtil.DeleteSyncPortableFile(existing_name); } (fi_.GetFolder as Folder).CopyHere(dest_item, copy_options); if (synchronous) { WinUtil.WaitForPortableCopyComplete(FullPath + "\\" + souce_name, file.Size); } }
public void DeleteAsync() { Task.Run(() => WinUtil.DeleteSyncPortableFile(fi_)); }
public void DeleteSync() { WinUtil.DeleteSyncPortableFile(fi_); }