首页 > 解决方案 > C# 从 github 下载文件

问题描述

我创建了一个自动更新的程序,通过从 github 下载更新的版本。但是程序一直在下载网页的源 html 而不是程序。我使用的链接是https://github.com/PoH98/MyBot.Supporter/raw/master/MyBot.Supporter.Main.exe并假设所有浏览器都会下载该 exe。但是当我使用 WebClient 进行下载时,它下载了https://github.com/PoH98/MyBot.Supporter/blob/master/MyBot.Supporter.Main.exe源 HTML 代码!我的代码在这里:

WebClient wc = new Webclient();
wc.Downloadfile("https://github.com/PoH98/MyBot.Supporter/raw/master/MyBot.Supporter.Main.exe","Update");
File.Delete("MyBot.Supporter.Main.exe");
File.Move("Update","MyBot.Supporter.Main.exe");

我做错了吗?

标签: c#

解决方案


推荐阅读