diff --git a/Sources/EasyExtensions.WebDav/WebDavCloudClient.cs b/Sources/EasyExtensions.WebDav/WebDavCloudClient.cs index 02aa96e..81fdd27 100644 --- a/Sources/EasyExtensions.WebDav/WebDavCloudClient.cs +++ b/Sources/EasyExtensions.WebDav/WebDavCloudClient.cs @@ -171,7 +171,7 @@ public async Task> GetResourcesAsync(string folder) { return Array.Empty(); } - return result.Resources; + return result.Resources.Where(x => x.Uri != url); } /// @@ -180,14 +180,20 @@ public async Task> GetResourcesAsync(string folder) /// The file path. /// The file bytes. public async Task GetFileBytesAsync(string filePath) + { + if (!await ExistsAsync(filePath)) + { + throw new FileNotFoundException("File not found.", filePath); + } + else { - string url = ConcatUris(_baseAddress, filePath).ToString(); - var file = await _client.GetRawFile(url); + string requestUri = ConcatUris(_baseAddress, filePath).ToString(); + WebDavStreamResponse webDavStreamResponse = await _client.GetRawFile(requestUri); using MemoryStream memoryStream = new MemoryStream(); - await file.Stream.CopyToAsync(memoryStream); - byte[] bytes = memoryStream.ToArray(); - return bytes; + await webDavStreamResponse.Stream.CopyToAsync(memoryStream); + return memoryStream.ToArray(); } + } /// /// Gets the underlying .