获取与C#中的ProcessStartInfo一起使用的可用动词(文件关联)列表 [英] Get List of available Verbs (file association) to use with ProcessStartInfo in c#

查看:380
本文介绍了获取与C#中的ProcessStartInfo一起使用的可用动词(文件关联)列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ProcessStartInfo类打开和打印文件. (文件可以是任何东西,但假设它是PDF文件)

I am trying to open and print files with the ProcessStartInfo class. (File can be anything but let`s assume it is a PDF File)

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

这对于pi.Verb = "OPEN";效果很好.某些应用程序还使用动词"PRINT"进行注册,但只有某些应用程序注册.就我而言(Windows PDF Viewer)在尝试使用pi.Verb = "PRINT";

this works well for the pi.Verb = "OPEN";. Some applications register themselves also with the verb "PRINT" but only some do. In my case (Windows PDF Viewer) I get an exception when trying to execute with the pi.Verb = "PRINT";

有没有办法在运行时查看C#中可用于特定类型的所有动词?

Is there a way to see all the verbs available for a specific type in C# at runtime?

非常感谢

推荐答案

从MSDN:

这篇关于获取与C#中的ProcessStartInfo一起使用的可用动词(文件关联)列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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