Reputation: 344
I've just downloaded a .zip file with RestSharp and it works great. Here is my code:
private void button3_Click(object sender, EventArgs e)
{
var client = new RestClient("http://xxx:3080");
var request = new RestRequest("/xxx/api/download/book/46795403-de-DE", Method.GET);
request.AddHeader("Authorization", "Bearer Tokenxxx");
client.DownloadData(request).SaveAs("C:/Users/xxx/Desktop/myRestSharpResponse.zip");
}
How can i unzip the files automatically now?
Upvotes: 1
Views: 1571
Reputation: 38179
To unzip your file using ZipFile:
const string zipPath = @"C:/Users/xxx/Desktop/myRestSharpResponse.zip";
const string extractPath = @"C:/Users/xxx/Desktop/ExtractFolder";
client.DownloadData(request).SaveAs(zipPath);
ZipFile.ExtractToDirectory(zipPath, extractPath);
Upvotes: 1