可能重复: How将文件扩展名关联到当前的可执行文件在C#
我不知道究竟如何调用这个问题。
I dont know how exactly to call this issue.
我要寻找一个解决方案,如:当该应用程序定义的filetyle是打开我的.NET应用程序会自动打开
I am looking for a solution such as: my .net application will be automatically opened when a filetyle defined for that application is open.
例如:该应用程序的文件类型有一个扩展XYZ:hellothere.xyz
For example: the filetype of that application has an extension xyz: hellothere.xyz
无论何时,用户的扩展名XYZ那么.NET应用程序将打开打开文件。我怎样才能做到这一点?
Whenever, the user opens the file with an extension "xyz" then that .net application will be opened. How can I achieve this?
在此先感谢。
一个文件关联,可手动在Windows文件夹选项创建的。 这篇文章介绍如何做到这一点编程,为例如有一个注册表文件:
A file association can be created manually in Windows Folder Options. This article describes how to do it programmatically, for example with a registry file:
创建一个字符串键为您的文件扩展名 HKEY_CLASSES_ROOT
的名为.xyz
。
它的值设置为你的文件类型,例如, XyzDocument
。
Set its value to the name of your file type, e.g., XyzDocument
.
创建一个字符串键 HKEY_CLASSES_ROOT \ XyzDocument \开放\壳\命令
。
它的值设置为路径\到\你\程序%1
或类似的,按您的需求。
Set its value to "path\to\your\program" "%1"
or similar, per your needs.
您也可以做到这一点从批处理脚本 FTYPE
和 assoc命令
:
You can also do it from a batch script with ftype
and assoc
:
ftype XyzDocument="path\to\your\program" "%1"
assoc .xyz=XyzDocument