public bool Rename(IFileSystemItem item, string newName, bool overwrite = false) { FtpExists exists = overwrite ? FtpExists.Overwrite : FtpExists.Skip; string currentPath = item.GetUri().AbsolutePath; try { if (item.IsDirectory()) { string upperPath = IO.Path.GetFullPath(IO.Path.Combine(currentPath, "..")); string destUri = IO.Path.GetFullPath(IO.Path.Combine(upperPath, newName)); return(client.MoveDirectory(currentPath, destUri, exists)); } else { string destUri = IO.Path.GetFullPath(IO.Path.Combine(currentPath, newName)); return(client.MoveFile(item.GetUri().AbsoluteUri, destUri, exists)); } } catch (Exception e) { ExceptionHandler.LogException(e); } return(false); }
public bool Delete(IFileSystemItem item) { try { if (item.IsDirectory()) { client.DeleteDirectory(item.GetUri().AbsolutePath); return(!client.DirectoryExists(item.GetUri().AbsoluteUri)); } else { client.DeleteFile(item.GetUri().AbsoluteUri); return(!FileExists(item.GetUri().AbsoluteUri)); } } catch (Exception e) { ExceptionHandler.LogException(e); } return(false); }
public bool Move(IFileSystemItem item, Directory destDirectory, bool overwrite = false) { FtpExists exists = overwrite ? FtpExists.Overwrite : FtpExists.Skip; string destPath = destDirectory.GetUri().AbsolutePath; try { if (item.IsDirectory()) { return(client.MoveDirectory(item.GetUri().AbsolutePath, destPath, exists)); } else { return(client.MoveFile(item.GetUri().AbsoluteUri, destPath, exists)); } } catch (Exception e) { ExceptionHandler.LogException(e); } return(false); }