本文介绍了有关更改Environment.CurrentDirectory的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何在Environment.CurrentDirectory发生更改时得到通知我的事件吗?实际上,Enviroment.CurrentDirectory可以在应用程序运行时更改.例如,当某个控件问您要在其中保存文档的路径时,它将保存该文档.所以我需要得到通知..因为在程序中可以通过多种方式将Enviroment.CurrentDirectory更改为其他dll.

Does anybody knows how can i get an event which will notify me when Environment.CurrentDirectory has changed?In fact, Enviroment.CurrentDirectory can change while application is running. For example, when some control ask you a path where you want to save a document and it saves it. So i need to be notified about it..because in a program can be a lot of ways to change Enviroment.CurrentDirectory into other''s dll.

推荐答案

但是,如果要在不运行应用程序时检查是否有人将exe移到了新位置,则可以将该位置放置在注册表/数据库/配置文件中.然后,在每次启动时(即,第一种形式的Load事件),您可以检查值是否相同,然后采取措施.

However if you want to check if someone has moved the exe to new location while applciation was not running, you can place the location in registry/database/config file. Then at each start up i.e. Load event of very first form, you can check if the value is same and then take action.


这篇关于有关更改Environment.CurrentDirectory的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 10:47