使用下面的代码,但它根本没有将任何文件下载到名为 myImages 的指定子文件夹到应用程序...我该如何解决这个问题?链接在这里纯粹是一个例子,通常链接将是一个变量,并且它自己填充没有问题。这一切都在 BackgroundWorker 中完成,否则 100% 正常工作。
//File to download
string _fileToDownload = "http://www.codeproject.com/images/download24.png"
//Path to download files
string _filePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "MyImages\\download24.png'";
//Download the image
using (var webClient = new WebClient())
{
webClient.DownloadFileAsync(new Uri(_fileToDownload ), @_filePath);
}
谢谢。
最佳答案
好的。 emmmmmmmmm 找到了我的答案:确实我可以使用 filedownload 方法,但输入正确的保存路径对我很有用...这是正确的路径,我忘了在我的文件夹名称前放一个\...
string _filePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\MyImages\\download24.png'";
关于C# 下载文件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17365991/