Untitled
user_2299906
plain_text
2 years ago
1.3 kB
2
Indexable
Never
public Task DownloadFile(string url, string pathfile) { var res = Task.Run(async() => { try { request = new RestRequest(url); request.AddHeader("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"); request.AddHeader("sec-fetch-site", "same-origin"); request.AddHeader("sec-fetch-dest", "empty"); request.AddHeader("accept-language", "en-US,en;q=0.9"); request.AddHeader("sec-fetch-mode", "cors"); //request.AddHeader("referer", "https://www.facebook.com/"); request.AddHeader("sec-ch-ua-platform", "\"Windows\""); request.Method = Method.Get; var temp =await Client.DownloadDataAsync(request); if (temp != null) File.WriteAllBytes(pathfile, temp); } catch (Exception e) { File.WriteAllText(Environment.CurrentDirectory + "\\Log_DownLoad.txt" , e.ToString() + "\n"); } }); return res; }