我想从云端下载文件夹/目录,现在我只能下载文件。
我如何下载和目录?
代码:
void Update()
{
string url = "url/file.txt";
if(!string.IsNullOrEmpty(url))
{
Thread threat = new Thread(() =>
{
Uri uri = new Uri(url);
string filename = Path.GetFileName(uri.AbsolutePath);
client.DownloadFileAsync(uri, File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Astro And Aliens Launcher\GameFilesPath.txt") + "/" + filename);
});
threat.Start();
}
}
private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
MessageBox.Show("Update Complete!", "Message", MessageBoxButton.OK, MessageBoxImage.Information);
}
private void Client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
Dispatcher.Invoke(new System.Windows.Forms.MethodInvoker(delegate ()
{
UpdateProgress.Minimum = 0;
double receive = double.Parse(e.BytesReceived.ToString());
double total = double.Parse(e.TotalBytesToReceive.ToString());
double percentage = receive / total * 100;
updatePercentText.Content = $"Downloaded {string.Format("{0:0.##}", percentage)}%";
UpdateProgress.Value = int.Parse(Math.Truncate(percentage).ToString());
}));
}