大家好,我在 WebClient 中遇到问题问题是我无法使用 WebClient.downloadFile 或 WebClient.DownloadFileAsync 下载特定文件,错误是 [请求已中止:无法创建 SSL/TLS 安全通道] 和下载的文件是 0bytes 请帮助我下载文件或为我的问题提供解决方案的任何代码我的代码是:
WebClient Client = new WebClient();
Client.DownloadFile("https://github.com/MohammedZr/roepo/blob/master/x82bit/32bit.exe", @"C:\Users\MohamedAlzurghni\Desktop\Project\bolo\test\32bit.exe");
Run Code Online (Sandbox Code Playgroud)
将安全协议设置为 Tls12
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
WebClient Client = new WebClient();
Client.DownloadFile("https://github.com/MohammedZr/roepo/blob/master/x82bit/32bit.exe", @"C:\Users\MohamedAlzurghni\Desktop\Project\bolo\test\32bit.exe");
Run Code Online (Sandbox Code Playgroud)