简体   繁体   English

在 VB.NET 中打开一个文件(Access 中的.mdb 文件)

[英]Open a file (.mdb file in Access) in VB.NET

I want to open a mdb file through VB.NET我想通过VB.NET打开一个mdb文件

Currently, I use:目前,我使用:

retval = shell("explorer.exe " & filename)

where filename includes the path.其中文件名包括路径。 It should open the mdb file in Microsoft Access.它应该在 Microsoft Access 中打开 mdb 文件。

This works fine on Windows 7 (my system), but when I try it on Windows XP (client machine) it comes up with the file download security warning dialog asking to Open, Save or Cancel.这在 Windows 7(我的系统)上运行良好,但是当我在 Windows XP(客户端计算机)上尝试时,它会出现文件下载安全警告对话框,要求打开、保存或取消。 If I click Open it presents the same dialog but now with Save and Cancel only.如果我单击“打开”,它会显示相同的对话框,但现在只有“保存”和“取消”。

I am sure there is a quick and easy way to open a file in its proper program through VB.NET.我确信有一种快速简便的方法可以通过 VB.NET 在适当的程序中打开文件。 I know I can open the database using Interop, but I don't want to go down that route.我知道我可以使用 Interop 打开数据库,但我不想 go 沿着这条路线走。

Thanks谢谢

You can use Process.Start to launch a program.您可以使用Process.Start启动程序。 Some good examples here: http://www.dotnetperls.com/process-start-vbnet这里有一些很好的例子: http://www.dotnetperls.com/process-start-vbnet

For example:例如:

System.Diagnostics.Process.Start("database.mdb")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM