打开一个文件,一个.NET应用程序会识别它? [英] open a file and a .net application will recognize it?

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

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/69761/how-to-associate-a-file-extension-to-the-current-executable-in-c-sharp">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

这篇关于打开一个文件,一个.NET应用程序会识别它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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