【发布时间】:2020-11-21 23:29:20
【问题描述】:
我有一个 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) 部分遇到错误,我该如何解决?
【问题讨论】:
-
这能回答你的问题吗? Get current folder path
-
那没有回答我的问题。
-
然后解释一下你想做什么
标签: c# .net visual-studio winforms winforms-to-web