据我所知,c#我不明白为什么这行不通。
我正在尝试从Maven存储库(https://repo1.maven.org/maven2/)下载文件
这是我的代码:
public static void Main(string[] args)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
try
{
var wcl = new WebClient();
wcl.DownloadFile("https://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.11/2.3.3/akka-actor_2.11-2.3.3.jar", "C:/minecraft_test/mcassets/libraries/test/test.file");
}
catch (Exception ex)
{
Console.WriteLine("error");
}
}
我有一个例外:从传输流接收到意外的EOF或0字节。
我尝试更改/删除行:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
但是我仍然遇到同样的错误。
我尝试过pwoershell:
$webclient = new-object System.Net.WebClient;
$webclient.DownloadFile("https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar", "C:/minecraft_test/mcassets/libraries/test/test.jar");
并且正在工作...
我该怎么解决?
最好的问候,谢谢
wcl.DownloadFile("https://repo1.maven.org/maven2/com/typesafe/akka/akka-actor_2.11/2.3.3/akka-actor_2.11-2.3.3.jar", "C:/minecraft_test/mcassets/libraries/test/test.file");
。
尝试删除路径中的'.file',我相信它将解决问题。
而且您也不需要使用以下代码:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;