关闭/重新启动之前备份文件 [英] backup of file before shutdown/restarting

查看:84
本文介绍了关闭/重新启动之前备份文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在C盘上有一个文件夹,其名称为(Data).

我想在关机或重新启动之前将文件夹备份到D驱动器上.当我关闭计算机时,软件会自动在D盘上创建文件夹(数据),如果文件夹已经存在,则会询问是否正确.有没有人可以帮助我..?


hi there,

i have one folder with name (Data) on C Drive.

i want folder backup on D Drive before shutdown or restart. when i give shutdown then software automatically create folder (Data) on D Drive, if Folder is already exist then it ask about over right. can any body help me..?


推荐答案

这可以使用类Microsoft.Win32.SystemEvents完成.请参阅:
http://msdn.microsoft.com/en-us/library/microsoft.win32. systemevents.aspx [ ^ ].

注意静态事件Microsoft.Win32.SystemEvents.SessionEndingMicrosoft.Win32.SystemEvents.SessionEnding.您向其中的任何一个添加事件句柄,检查结束原因,该原因在事件参数中传递给您,并在会话实际结束之前执行操作.有趣且重要的是,如果SessionEnding您甚至可以取消结尾,这将有效地延迟关闭或重新启动,直到用户允许通过忽略您的应用程序或检查是否可以安全结束该命令来强制关闭或重新启动它为止会议.请参阅:
http://msdn.microsoft.com/en-us/library/microsoft. win32.systemevents.sessionending.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/microsoft.win32. sessionendingeventargs.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/microsoft. win32.systemevents.sessionended.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/microsoft.win32. sessionendedeventargs.aspx [ ^ ].

—SA
This can be done using the class Microsoft.Win32.SystemEvents. Please see:
http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents.aspx[^].

Pay attention for the static events Microsoft.Win32.SystemEvents.SessionEnding and Microsoft.Win32.SystemEvents.SessionEnding. You add a event handle to any of them, check up the reason of ending, which is passed to you in event arguments, and perform the action before the session actually ends. Interestingly and importantly, in case if SessionEnding you can even cancel the ending, which will effectively delay shutdown or restart until the user allows to forcefully shutdown or restart it either by ignoring your application or checking if it''s safe to end the session. Please see:
http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents.sessionending.aspx[^],
http://msdn.microsoft.com/en-us/library/microsoft.win32.sessionendingeventargs.aspx[^],
http://msdn.microsoft.com/en-us/library/microsoft.win32.systemevents.sessionended.aspx[^],
http://msdn.microsoft.com/en-us/library/microsoft.win32.sessionendedeventargs.aspx[^].

—SA


这篇关于关闭/重新启动之前备份文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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