与关联的应用程序打开文件 [英] Open file with associated application

查看:257
本文介绍了与关联的应用程序打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻求帮助与相关应用从C#应用程序打开文件。
我想这样的:

i want to ask for help with opening a file from c# app with associated app. I tried this:

      ProcessStartInfo pi = new ProcessStartInfo(file);
      pi.Arguments = Path.GetFileName(file);
      pi.UseShellExecute = true;
      pi.WorkingDirectory = Path.GetDirectoryName(file);
      pi.FileName = file;
      pi.Verb = "OPEN";
      Process.Start(pi);

或本

      Process.Start(file);

其中字符串文件在这两个例子重presents完整路径,文件打不开。现在,一切都运作良好,除了使用ACDSee应用在(JPG)图像。 IrfanView的关联效果很好,MS Office文档了。试图打开使用ACDSee相关联的JPG图片后,它只是运行在通知区域中的ACDSEE,不打开该文件。

where string file in both examples represents full path to the file trying to open. Now, everything is working well, except the (jpg) images with ACDSee app. Irfanview associations works well, MS office documents too. After trying to open the jpg image associated with acdsee it just runs the acdsee in the notification area and does not open the file.

我发现,在注册表中的 CLASSES_ROOT 为* .jpg图像中,有一个ACDSee.JPG值相关联的应用程序,此项下有在用shell>打开 - >命令的路径:

I discovered, that in the registry CLASSES_ROOT for *.jpg images, there is an ACDSee.JPG value as associated app, and under this key there is in the shell->Open->Command a path:

"C:\Program Files\ACD Systems\ACDSee\ACDSee.exe" /dde

和我的事情,这个怪异的 / DDE 的原因,为什么我不能打开该文件。我意识到,在同样的注册表项的用shell>打开有一个与价值一定 DDEExec 键输入 [打开( %1)]

and I thing that this weird /dde is the reason, why i cannot open the file. I realized that in the same reg key shell->Open there is some DDEExec key entry with value [open("%1")]

有关伊尔凡视图或其他检查应用程序还没有一个ddeexec,只是正常的命令如

For Irfan view or other checked app there is not a ddeexec, just the normal command like

"C:\Program Files (x86)\IrfanView\i_view32.exe" "%1"

这可以从命令行swaping%1文件名<击>之后运行,但我不能在命令行ACDSEE进入运行命令:(

that can be run from command line after swaping the %1 for file name, but I could not run the command from acdsee entry in the command line :(

所以我的问题是,我怎么可以设置的ProcessStartInfo 对象为确保它将运行的所有文件,因为这将是探险家由DoubleClick的标准,这个 DDEExec 的呢?是否有其他类似 DDEExec ,我建议立即进行删除知道的?
感谢和抱歉我的EN

So my question is, how can I set up the ProcessStartInfo object to ensure that it will run all the files as it would be in the explorer by doubleclick, the standards and this DDEExec ones? Is there something other like DDEExec that I shoul be aware of? thanks and sorry for my EN

推荐答案

只要写

System.Diagnostics.Process.Start(@"file path");

例如

System.Diagnostics.Process.Start(@"C:\foo.jpg");
System.Diagnostics.Process.Start(@"C:\foo.doc");
System.Diagnostics.Process.Start(@"C:\foo.dxf");
...

和外壳将运行相关程序从注册表中读取它,像往常一样双击一样。

And shell will run associated program reading it from the registry, like usual double click does.

这篇关于与关联的应用程序打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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