public async Task Download(string destPath, File file) { bool unzip = false; if (file.Name.EndsWith("!**")) { file.Name = file.Name.Replace("!**", string.Empty); unzip = true; } if (file.Name == "**") { file.ContentHref = file.ChildrenHref.Replace("!/**", string.Empty); string[] parts = file.ContentHref.Split('/'); file.Name = parts[parts.Length - 1]; unzip = true; } var destFileName = BuildFullName(destPath, file); EnsureDirectoryExists(destFileName); using (Stream stream = await _http.GetStream(file.ContentHref)) { EnsureDirectoryExists(destFileName); if (System.IO.File.Exists(destFileName) == false) { await _fileSystem.CreateFileFromStreamAsync(destFileName, stream); } } if (unzip) { Log.Debug("Unzipping " + destFileName); var tempFileName = _fileSystem.CreateTempFile(); _fileSystem.CopyFile(destFileName, tempFileName, true); //if (_fileSystem.DirectoryExists(destPath)) //{ // _fileSystem.DeleteDirectory(destPath, true); //} _fileSystem.ExtractToDirectory(tempFileName, destPath); _fileSystem.DeleteFile(tempFileName); } }