检查未保存的更改并要求用户保存 [英] Check for unsaved changes and ask user to save

查看:30
本文介绍了检查未保存的更改并要求用户保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个扩展程序,用于向解决方案中的项目添加文件.

I'm writing an extension which adds files to projects in the solution.

首先检查未保存的更改是有意义的,如果有,请要求用户保存.

It makes sense to check first for unsaved changes and if there are any, ask user to save.

我怎样才能做到这一点?

How can I achieve this?

是否有任何开源 VS 扩展可以做到这一点,以便我看看它是如何完成的?

Are there any open source VS extensions which do this so I can take a look how it's done?

推荐答案

要查看是否有未保存的更改,您可以使用 DTE.Documents 并检查每个文档的 Document.Saved 属性.

To find out if there are unsaved changes, you can enumerate open documents with DTE.Documents and check each one for the Document.Saved property.

这篇关于检查未保存的更改并要求用户保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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