问题描述
尝试从ftp下载文件时出现以下错误。
发现System.Exception HResult = -2147012893消息=来自HRESULT的异常:0x80072EE3 Source = mscorlib StackTrace:at System.Runtime System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()上的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中的.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)
谁能告诉我我做错了什么?
提前致谢!
我尝试了什么:
以下是我使用的代码 -
I am getting below error when trying to download a file from ftp.
System.Exception was caught HResult=-2147012893 Message=Exception from HRESULT: 0x80072EE3 Source=mscorlib StackTrace: at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
can anyone tell me what am I doing wrong ?
Thanks in advance!
What I have tried:
Below is the code I am using-
public static async Task<bool> LargeDownLoad(string localsubfolders, string ftpURIInfo, string Username, string Password, string filename)
{
bool Successful = false;
try
{
StorageFolder localFolderArea;
BackgroundDownloader downloader = new BackgroundDownloader();
// Open if exists as you cannot delete it if there are files in it.
localFolderArea = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync(localsubfolders, CreationCollisionOption.OpenIfExists);
// create a storagefile which combines the localFolderArea with the filename of the local file.
StorageFile localFilePath = await localFolderArea.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
Uri urlWithCredential; // = new Uri(ftpURIInfo + "/" + filename);
bool Success = Uri.TryCreate(ftpURIInfo + "/" + filename, UriKind.Absolute, out urlWithCredential);
if (!string.IsNullOrEmpty(Username.Trim()) &&
!string.IsNullOrEmpty(Password.Trim()))
{
urlWithCredential = new Uri(urlWithCredential.ToString().ToLower().Replace(@"ftp://",
string.Format(@"ftp://{0}:{1}@",
Username,
Password)));
}
DownloadOperation download = downloader.CreateDownload(
urlWithCredential,
localFilePath);
await download.StartAsync();
Successful = true;
}
catch (Exception)
{
throw;
}
return Successful;
}
推荐答案
这篇关于来自HRESULT的异常:0x80072ee3 - backgrounddownloader winrt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!