在 "Download" 文件夹中下载图像

Download image in "Download" folder

我的应用程序中有图像。当我尝试在 Downloads folder 中下载我电脑上的图像时,它正在下载文件夹中创建一个 新文件夹 ,并将我的图像保存在那里。

为什么此方法会创建一个新文件夹而不是仅将文件下载到“下载”文件夹?

    public async void DownLoadImage()
    {
        var url = SelectedAsset?.VumarkImage?.AbsoluteUrl;
        if (string.IsNullOrEmpty(url))
        {
            return;
        }

        if (!Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
        {
            return;
        }

        var source = new Uri(url);

        StorageFile destinationFile = await DownloadsFolder.CreateFileAsync(SelectedAsset.VumarkImage.OriginalName, CreationCollisionOption.GenerateUniqueName);

        BackgroundDownloader downloader = new BackgroundDownloader();
        DownloadOperation download = downloader.CreateDownload(source, destinationFile);
        await download.StartAsync();
        _toastService.Show("Vumark successfully downloaded to Downloads folder");
    }

这是预期的行为。它似乎没有记录在案;我opened an issue.

API 将为调用应用程序创建一个特定的子文件夹,以将 files/folders 放入使用 DownloadsFolder API.

创建的文件夹中

要将文件直接保存到“下载”文件夹,您必须让用户使用 FileSavePicker or get them to choose a 'default folder' with the FolderPicker and use that, just remember to save a reference 选择该位置以备将来使用。