[WinRT] FTP download



  • Hallo ihr,

    ich habe folgendes Problem:
    ich habe eine App geschrieben und versuche eine Datei von FTP herunterzuladen allerding geht das irgendwie nciht! Ich bekommen immer eine Exception

    Error HRESULT E_FAIL has been returned from a call to a COM component.
    

    Der Code sieht folgendermassen aus:

    try
                    {
                    NetworkCredential credential = new NetworkCredential();
                    credential.Domain = "*****";
                    credential.Password = "*****";
                    credential.UserName = "*****";
    
                    Uri url = new Uri(@"ftp://*****");
                    Uri urlWithCredential;
    
                    urlWithCredential = new Uri(url.ToString().ToLower().Replace(@"ftp://",
                            string.Format(@"ftp://{0}:{1}@",
                            EncodeUrl(credential.UserName),
                            EncodeUrl(credential.Password))) + @"htdocs/repository/list.xml");
    
                    string destination = "list.xml";
    
                    StorageFile destinationFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(
                        destination, CreationCollisionOption.ReplaceExisting);
    
                    BackgroundDownloader downloader = new BackgroundDownloader();
                    DownloadOperation download = downloader.CreateDownload(urlWithCredential, destinationFile);
                    await download.StartAsync();
    
                    return await ApplicationData.Current.LocalFolder.GetFileAsync(destination);
                    }
                catch (Exception ex)
                    {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                    return null;
                    }
    

    Ist da irgendwas falsch dran? Gibt es alternativen? btw. wenn ich die in urlWithCredential hinterlegte url im Browser eingebe, öffnet sich auch die richtige Datei!

    Danke für eure Hilfe!!!



  • Schreib zumindest dazu, in welcher Zeile die Exception fliegt.


Anmelden zum Antworten