/// <summary> /// Moves the underlying directory. /// </summary> /// <param name="destinationRelativePath"></param> /// <exception cref="ArgumentException"></exception> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="AccessDeniedException"></exception> /// <exception cref="DirectoryNotFoundException"></exception> /// <exception cref="PathTooLongException"></exception> /// <exception cref="FileStorageException"></exception> public async Task MoveAsync(string destinationRelativePath) { if (destinationRelativePath == string.Empty) { throw new ArgumentException($"Value can't be empty. Parameter name: destinationRelativePath."); } if (destinationRelativePath == null) { throw new ArgumentNullException($"Value can't be null. Parameter name: destinationRelativePath.", default(Exception)); } try { using (DropboxClient dropboxClient = new DropboxClient(this.accessToken)) await dropboxClient.Files.MoveV2Async(this.path, RelativeUrl.Combine(this.rootPath, destinationRelativePath)); } catch (ApiException <RelocationError> e) { if (e.ErrorResponse.IsFromLookup) { throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e); } throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e); } catch (Exception e) { throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e); } }
/// <summary> /// Initializes a new instance of the <see cref="FileProxy">FileProxy</see> class. /// </summary> /// <param name="accessToken">The Dropbox's account access token.</param> /// <param name="rootPath">The root path of the underlying file's relative one.</param> /// <param name="relativePath">The path of the underlying file relatively to the root one.</param> /// <param name="filename">The filename of the underlying file.</param> /// <exception cref="ArgumentException"></exception> /// <exception cref="ArgumentNullException"></exception> public FileProxy(string accessToken, string rootPath, string relativePath, string filename) { if (accessToken == string.Empty) { throw new ArgumentException($"Value can't be empty. Parameter name: accessToken."); } if (accessToken == null) { throw new ArgumentNullException($"Value can't be null. Parameter name: accessToken.", default(Exception)); } if (filename == string.Empty) { throw new ArgumentException($"Value can't be empty. Parameter name: filename."); } if (filename == null) { throw new ArgumentNullException($"Value can't be null. Parameter name: filename.", default(Exception)); } this.accessToken = accessToken; this.rootPath = rootPath; this.RelativePath = relativePath; this.Filename = filename; this.filepath = RelativeUrl.Combine(this.rootPath, this.RelativePath, this.Filename); }
/// <summary> /// Initializes a new instance of the <see cref="DirectoryProxy">DirectoryProxy</see> class. /// </summary> /// <param name="accessToken">The Dropbox's account access token.</param> /// <param name="rootPath">The root path of the underlying directory's relative one.</param> /// <param name="relativePath">The path of the underlying directory relatively to the root one.</param> /// <exception cref="ArgumentException"></exception> /// <exception cref="ArgumentNullException"></exception> public DirectoryProxy(string accessToken, string rootPath, string relativePath) { if (accessToken == string.Empty) { throw new ArgumentException($"Value can't be empty. Parameter name: accessToken."); } if (accessToken == null) { throw new ArgumentNullException($"Value can't be null. Parameter name: accessToken.", default(Exception)); } this.accessToken = accessToken; this.rootPath = RelativeUrl.Combine(rootPath); this.RelativePath = RelativeUrl.Combine(relativePath); this.path = RelativeUrl.Combine(this.rootPath, this.RelativePath); if (string.Equals(this.path, "/")) { this.path = string.Empty; } }