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();
localFolderArea = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync(localsubfolders, CreationCollisionOption.OpenIfExists);
StorageFile localFilePath = await localFolderArea.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
Uri urlWithCredential;
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;
}