C#访问一个地址的时候需要用户名密码,需要怎么写程序

2025-04-08 14:00:18
推荐回答(1个)
回答1:

WebClient webClient = new WebClient();
webClient.Credentials = new NetworkCredential(USERNAME, PASSWORD);

webClient.DownloadFile(URL, Server.MapPath("xml"));