c# - 无法在 C# 程序中下载 JDK
问题描述
我正在尝试编写一个需要jdk
在机器上下载的 C# 程序。我写了一些代码,但每次只能下载 3-4 kb
static void Main(string[] args)
{
WebClient client = new WebClient();
string address = "https://download.oracle.com/otn/java/jdk/8u211-b12/478a62b7d4e34b78b671c754eaaf38ab/jdk-8u211-windows-x64.exe";
Uri uri = new Uri(address);
var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string fileName = desktop + "\\jdk.exe";
Console.WriteLine("Downloading file");
client.DownloadFile(address, fileName);
Console.WriteLine("Done Downloading File");
Console.ReadLine();
}
解决方案
如果你把地址放在浏览器中,你很快就会明白为什么。
下载 JDK8 需要您现在登录。他们为旧版本的 Java 执行此操作。我相信 JDK8 大约在一个月前开始了这种行为。
推荐阅读
- html - XSL 的放置位置:选择条件
- java - Eclipse MAT 的 ParseHeapDump 实用程序可以运行 OQL 吗?
- reporting-services - SSRS Rest API - 获取扩展设置
- python - 消息:无效参数:无法在 python 中终止已退出的进程
- java - 添加年份的Java日历问题
- java - 如何在没有 iBatis 的情况下在 JDBC 中运行 SQL 脚本?
- r - 条件渲染数据表
- php - shell_exec() 在前面的 echo 语句之前执行
- google-apps-script - 关于 Google 表格/日历的旧问题的新答案
- c# - 如何使用 Selenium 3.141 和 C# 执行 Android 和 iOS 设备测试?