Hi,DavidThielen-2188
You can use WebClient.DownloadFile() to download the file from url and set authentication at the same time, like:
DownloadFileFromUrl
using (System.Net.WebClient wc = new System.Net.WebClient())
{
wc.Headers.Add("Cookie: Authentication=user"); // add a cookie header to the request
try
{
string filename = System.Guid.NewGuid().ToString("N"); // use global unique identifier for file name to avoid conflicts
wc.DownloadFile("http://www.prowaretech.com/", "C:\\files\\" + filename); // could add file extension here
// do something with file
}
catch (System.Exception ex)
{
// check exception object for the error
}
}
Best Regards,
Jerry Cai
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.