在 VB.NET 中检查使用 process.start() 启动的文件中的更改 [英] In VB.NET check for changes in a file launched with process.start()

查看:78
本文介绍了在 VB.NET 中检查使用 process.start() 启动的文件中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个基于 vbnet/c#.NET 的应用程序,它可以使用不同的应用程序(excel、word 等)打开文件.

I'm developing a vbnet/c#.NET based application that opens files with different applications(excel, word, etc).

使用 Dim app As Process = Process.Start(ProcessProperties)

现在,当我必须终止进程时,我使用 app.Kill() 但我需要在杀死它之前检查文档是否已被修改.

Now, when I have to terminate the process I use app.Kill() but I need to check if the document has been modified before killing it.

我该如何处理?如果可能,我该如何启动应用程序本机提示以进行保存?

How can I handle that? And if it's possible, how can I launch the application native prompt for save?

谢谢

推荐答案

对于办公应用程序,请使用 Office 互操作程序集,而不是 Process.Start 来启动和控制它们.这是 Excel 的示例代码(在 VB.NET 中).您应该将 Microsoft.Office.Interop.Excel.dll 添加到项目引用中以使其正常工作.

For office applications use Office Interop Assemblies, not Process.Start to start and control them. Here is an example code for Excel (in VB.NET). You should add Microsoft.Office.Interop.Excel.dll to the project references in order for this to work.

   oExcel = New Microsof.Office.Interop.Excel.Application
   oBook = oExcel.Workbooks.Open(filepath)
   'Do your stuff
   oBook.Close 'This will trigger the application native prompt if the document was modified
   oExcel.Quit()

对于其他程序,它在很大程度上取决于程序

For other programs it depends much on a program

这篇关于在 VB.NET 中检查使用 process.start() 启动的文件中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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