【发布时间】:2021-07-19 00:35:53
【问题描述】:
我正在为游戏服务器制作启动器。如何让游戏下载并解压缩。我准备了一个 zip 文件,我希望它自动下载并安装“C:\Program Files”。
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
namespace WindowsFormsApp3
{
public partial class Form1 : Form
{
WebClient web = new WebClient();
public Form1()
{
InitializeComponent();
}
private void DosyaIndirmeTamamlandiUyarisi(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("Download Completed");
}
private void Download_Click(object sender, EventArgs e)
{
web.DownloadFileCompleted += new AsyncCompletedEventHandler(DosyaIndirmeTamamlandiUyarisi);
Uri DosyaAdresi = new Uri(textBox1.Text);
web.DownloadFileAsync(DosyaAdresi, textBox1.Text.Length.ToString()+".zip");
}
}
}
【问题讨论】:
-
您在为哪一部分苦苦挣扎?看起来您设法下载了该文件。第二个任务见How to: Compress and extract files。另外,请注意,为了访问
%ProgramFiles%文件夹,您需要提升您的进程(AKA,以管理员身份运行)。 -
我试过这样,但它没有解压缩。 pastecode.io/s/1hija2BtUu