HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://q2.s4.jc9.ru/filecpd.php?u=aHR0cHM6Ly9kYXRhLmpjOS5ydS9pbWFnZXMvX2pjdHJhZGUvMjAxNzAyLzE4LzAwMDk3OS9qY3RyYWRlMTQ4NzM5NzIzMy04NzYxNy02MjgxOTEuanBn&tp=custom&w=1280&h=960&s=1&l&nocrop&sc=88c93&ver=2");
req.Timeout = 10000;
req.AllowAutoRedirect = false;
req.ContentType = "GET";
req.ServicePoint.Expect100Continue = false;
req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36 OPR/43.0.2442.806";
req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
req.Headers.Add("Accept-Encoding", "gzip, deflate, sdch, br");
req.Headers.Add("Accept-Language", "ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4");
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
using (Stream respStream = resp.GetResponseStream())
{
string name = resp.GetResponseHeader("Content-disposition").Split('=')[1];
byte[] buffer = new byte[2048];
int bytesRead = 0;
using (FileStream fs = new FileStream(@"C:\" + name, FileMode.Create, FileAccess.Write))
{
while ((bytesRead = respStream.Read(buffer, 0, buffer.Length)) > 0)
{
fs.Write(buffer, 0, bytesRead);
}
}
}