应用关闭时复制文件 [英] Copy a file when App is closed

查看:64
本文介绍了应用关闭时复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个在AppData /../ LocalState中使用SqLite数据库的UWP应用程序。到目前为止,缺少的是将数据库文件自动备份到用户定义的存储位置。

I developed a UWP app that uses a SqLite database in AppData/../LocalState. What is missing so far is an automatic backup of the database file to a user-defined storage location.

我想在应用程序终止时进行备份,以避免在应用程序中进行过多复制正在使用。我已经阅读了很多关于Suspend处理程序和可能的BackgroundTask来做到这一点,但我仍然不确定最佳解决方案是什么。可以
有人对此有所了解吗?是否有可能有这样的后台任务,也可以应对如下错误:存储位置是USB磁盘,但它不可用。我认为后台任务可以发出Toasts来提醒用户,但它真的可以
与用户交互吗?

I would like to do the backup when the app terminates to avoid excessive copying while the app is being used. I have read a lot about a Suspend handler and a possible BackgroundTask to do this but I am still not sure what the best solution would be. Can someone shed some light on this? Is it possible to have such a background tasks that also would cope with errors like: the storage location is a USB disk but it is not available. I think a background task can issue Toasts to alert the user, but can it really interact with the user?

推荐答案

您好, 

Hello, 

请阅读粘贴帖子,尤其是  发布指南:主题行
标签
和don'忘记在你的问题中添加标签。

Please read the sticky posts, especially the Guide to posting: subject line tags, and don't forget add tag to your question.

暂停处理程序不是最好的地方,因为它限制了执行时间。进程外后台任务是最佳选择。您可以与用户购买吐司通知进行互动。

The suspension handler is not a best place because it has restriction for execution time. The out of process background task is the best choice. And you can interact with user buy toast notifications.


这篇关于应用关闭时复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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