UWP FileSavePicker 合同文件处理 [英] UWP FileSavePicker Contract File Processing

查看:13
本文介绍了UWP FileSavePicker 合同文件处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我使用的是 FileSavePicker 合同(提供者).所以其他应用程序可以将文件保存到我的应用程序中.我实现了它,如 MSDN 上所示.现在的问题是,我必须处理一个已保存"的文件,但是我怎么知道保存完成时?这是我的处理程序

In my App i'm using a a FileSavePicker Contract (Provider). So other Apps could save files to my App. I implemented it, as it is shown on MSDN. The Problem now is, that i have to process a "saved" file, but how do i know, when the saving is completed? Here is my handler

private async void FileSavePickerUI_TargetFileRequested(FileSavePickerUI sender, TargetFileRequestedEventArgs args)
{
        var deferral = args.Request.GetDeferral();

        string saveFileName = sender.FileName;

        StorageFolder fileSavePickerContractTempFolder = await ApplicationData.Current.LocalCacheFolder.CreateFolderAsync("FileSavePickerContract", CreationCollisionOption.OpenIfExists);

        StorageFile fileSavePickerContractTempFile = await fileSavePickerContractTempFolder.CreateFileAsync(saveFileName, CreationCollisionOption.ReplaceExisting);

        args.Request.TargetFile = fileSavePickerContractTempFile;

        deferral.Complete();
    }

我的应用程序的目标是周年更新 (1607).在 deferral.Complete() 之后,我需要更多地使用该文件以集成到我的应用程序中.有人能指出我正确的方向吗?

Target of my app is the anniversary update (1607). After deferral.Complete() i Need to to more work with that file for integrating in my App. Can someone Point me in the right direction?

推荐答案

使用 CacheFileUpdater 我可以对文件做出反应,只要它完全写入

With the CacheFileUpdater i can react to the file, as soon it is written completely

CachedFileUpdater.SetUpdateInformation(fileSavePickerContractTempFile, url, ReadActivationMode.NotNeeded, WriteActivationMode.AfterWrite, CachedFileOptions.None);

在 App.xaml.cs 上,我现在覆盖OnCachedFileUpdaterActivated"事件,在该事件中我可以对完全写入的文件执行一些操作.所以这现在按预期工作.

On App.xaml.cs i override now the "OnCachedFileUpdaterActivated" Event, in which i can perform some Actions with the completely written file. So this works now as expected.

但是!这在 Windows 10 Mobile 上不起作用,App.xaml.cs 上的 OnCachedFileUpdaterActivated EventHandler 没有被触发,这是为什么?

BUT! This does not work on Windows 10 Mobile, there the OnCachedFileUpdaterActivated EventHandler on App.xaml.cs gets not fired, why is this?

这篇关于UWP FileSavePicker 合同文件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆