首页 > 解决方案 > 安全 FTP 下载在 UWP 中不起作用

问题描述

我尝试使用 BackgroundDownloader 类从安全的 FTP 服务器下载文件,但它没有下载,也没有抛出任何异常。

下面的 GetResponseInformation() 返回 null。

我提供如下输入 URL: ftp://username:password@hostIP/test.pdf

下面的代码:

            Uri uri = new Uri(ftpUrlBox.Text.Trim());
            StorageFile storageFile = await pickedFolder.CreateFileAsync("DownloadedFile.pdf", CreationCollisionOption.ReplaceExisting);

            BackgroundDownloader backgroundDownloader = new BackgroundDownloader();
            DownloadOperation downloadOperation = backgroundDownloader.CreateDownload(uri, storageFile);

            ftpBar.Visibility = Visibility.Visible;
            await downloadOperation.StartAsync();
            ftpBar.Visibility = Visibility.Collapsed;

            ResponseInformation responseInformation = downloadOperation.GetResponseInformation();
            ftpStatusText.Text = responseInformation != null ? responseInformation.StatusCode.ToString() : string.Empty;

请帮助如何从 UWP 中的安全 FTP 服务器下载和上传。

注意:如果我使用一些 3rd 方 nuget 库,则 FTP(S) 下载工作正常。但不适用于上述 UWP 代码。

标签: downloaduwpftpfile-transfer

解决方案


推荐阅读