我有这个功能:
public void DownloadFile(string urlAddress, string location)
{
using (webClient = new WebClient())
{
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
Uri URL = urlAddress.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ? new Uri(urlAddress) : new Uri("http://" + urlAddress);
sw.Start();
try
{
webClient.DownloadFileAsync(URL, location);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
}
DownloadFile(downloadUrl, path_to_up);
// path_to_up来自另一种方法
问题是如果path_to_up类似于:C:\ Program Files(x86)\ Test \ Program Test \ file.exe,则它不起作用。仅适用于D:\ FolderWithoutSpaces \ file.exe等路径。
我试过了:
@
path_to_up
\
替换为\\
DownloadFile(downloadUrl, @"C:\Program Files(x86)\Test\Program Test\file.exe");
在整个晚上搜索谷歌,但没有任何帮助我。 我怎么解决这个问题 ?非常感谢提前。