/wasDAVClient/Client.cs |
@@ -124,7 +124,7 @@ |
/// </summary> |
public int Timeout { get; set; } = 60; |
|
#endregion WebDAV connection parameters |
#endregion |
|
#region WebDAV operations |
|
@@ -134,13 +134,16 @@ |
/// <param name="path">List only files in this path</param> |
/// <param name="depth">Recursion depth</param> |
/// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
public async Task<IEnumerable<Item>> List(string path = "/", string depth = Constants.DavDepth.MEMBERS) |
public async Task<IEnumerable<Item>> List(string path = "/", int? depth = 1) |
{ |
var listUri = await GetServerUrl(path, true).ConfigureAwait(false); |
|
// Depth header: http://webdav.org/specs/rfc4918.html#rfc.section.9.1.4 |
IDictionary<string, string> headers = new Dictionary<string, string>(); |
headers.Add("Depth", depth); |
if (depth != null) |
{ |
headers.Add("Depth", depth.ToString()); |
} |
|
HttpResponseMessage response = null; |
|
@@ -174,7 +177,6 @@ |
{ |
case true: |
return item; |
|
default: |
// If it's not the requested parent folder, add it to the result |
if (!string.Equals((await GetServerUrl(item.Href, true).ConfigureAwait(false)).ToString(), |
@@ -213,6 +215,7 @@ |
return await Get((await GetServerUrl(path, false).ConfigureAwait(false)).Uri).ConfigureAwait(false); |
} |
|
|
/// <summary> |
/// List all files present on the server. |
/// </summary> |
@@ -308,6 +311,7 @@ |
} |
} |
|
|
/// <summary> |
/// Create a directory on the server |
/// </summary> |
@@ -353,6 +357,7 @@ |
await Delete((await GetServerUrl(href, false).ConfigureAwait(false)).Uri).ConfigureAwait(false); |
} |
|
|
private async Task Delete(Uri listUri) |
{ |
var response = await HttpRequest(listUri, HttpMethod.Delete).ConfigureAwait(false); |
@@ -382,6 +387,7 @@ |
(await GetServerUrl(dstFilePath, false).ConfigureAwait(false)).Uri).ConfigureAwait(false); |
} |
|
|
private async Task<bool> Move(Uri srcUri, Uri dstUri) |
{ |
const string requestContent = "MOVE"; |
@@ -405,7 +411,7 @@ |
return response.IsSuccessStatusCode; |
} |
|
#endregion WebDAV operations |
#endregion |
|
#region Server communication |
|
@@ -508,6 +514,7 @@ |
_encodedBasePath = root.Href; |
} |
|
|
// If we've been asked for the "root" folder |
if (string.IsNullOrEmpty(path)) |
{ |
@@ -559,6 +566,7 @@ |
baseUri.Path = finalPath; |
} |
|
|
return baseUri; |
} |
} |
@@ -569,6 +577,6 @@ |
_uploadClient?.Dispose(); |
} |
|
#endregion Server communication |
#endregion |
} |
} |
} |
/wasDAVClient/IClient.cs |
@@ -39,6 +39,7 @@ |
/// </summary> |
string UserAgentVersion { get; set; } |
|
|
/// <summary> |
/// List all files present on the server. |
/// </summary> |
@@ -45,19 +46,19 @@ |
/// <param name="path">List only files in this path</param> |
/// <param name="depth">Recursion depth</param> |
/// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
Task<IEnumerable<Item>> List(string path = Constants.DIRECTORY_SEPARATOR, string depth = Constants.DavDepth.MEMBERS); |
Task<IEnumerable<Item>> List(string path = "/", int? depth = 1); |
|
/// <summary> |
/// Get folder information from the server. |
/// </summary> |
/// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
Task<Item> GetFolder(string path = Constants.DIRECTORY_SEPARATOR); |
Task<Item> GetFolder(string path = "/"); |
|
/// <summary> |
/// Get file information from the server. |
/// </summary> |
/// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
Task<Item> GetFile(string path = Constants.DIRECTORY_SEPARATOR); |
Task<Item> GetFile(string path = "/"); |
|
/// <summary> |
/// Download a file from the server |
@@ -84,13 +85,13 @@ |
/// Get folder information from the server. |
/// </summary> |
/// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
Task DeleteFolder(string path = Constants.DIRECTORY_SEPARATOR); |
Task DeleteFolder(string path = "/"); |
|
/// <summary> |
/// Get file information from the server. |
/// </summary> |
/// <returns>A list of files (entries without a trailing slash) and directories (entries with a trailing slash)</returns> |
Task DeleteFile(string path = Constants.DIRECTORY_SEPARATOR); |
Task DeleteFile(string path = "/"); |
|
/// <summary> |
/// Move a folder on the server |