我有一个 Winforms 自动更新程序。
如果我打开程序,它将从包含 .zip 文件下载链接的原始文本中获取文件下载链接,该链接来自网络。
但是,如果该人创建了一个文件夹并将程序放在文件夹中,我希望程序获取程序所在的文件夹名称并将 zip 文件解压缩到该文件夹中。
这是我的代码:
private void StartDownload()
{
WebClient webClient = new WebClient();
string path = "./Sympathy";
string address1 = "https://ghostbin.co/paste/cjx7j/raw";
string address2 = webClient.DownloadString(address1);
this.progressBar1.Value = 100;
string str = "./Sympathy.zip";
if (System.IO.File.Exists(str))
{
System.IO.File.Delete(str);
}
else
{
webClient.DownloadFile(address2, str);
ZipFile.ExtractToDirectory(str, Directory.GetCurrentDirectory(Directory).Name);
System.IO.File.Delete(str);
}
}
但是我有一个错误,我该(Directory)
如何解决?