C#程序如何双击打开文件
我有一个 C# 程序,它可以处理自己创建的文件。可以通过运行该程序然后通过 GUI 访问该文件来打开该文件。
如何打开文件而无需显式运行程序,只需双击相关文件即可?
I have a C# program which works with files created by itself. The file can be opened by running the program and then accessing it via the GUI.
How can I open the file without having to run the program explicitly and just by double clicking on the concerned file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须在安装程序中添加注册表项,才能将程序的文件扩展名与应用程序关联起来。
以下是 MSDN 中的一篇文章,它将告诉您需要了解的有关文件关联的信息:文件关联如何工作
You have to add registry entries in your installer to associate your program's file extension with your application.
Here is an article in MSDN that will tell you what you need to know about file associations: How File Associations Work
通常,您会在安装时执行此操作,如果您不使用安装程序或 ClickOnce,那么您可以通过代码执行此操作,但您必须在注册表中进行操作: http://mel-green.com/2009/04/c-set-file-type-association/< /a>
Typically you'd do this with your install, if you're not using an installer or ClickOnce, then you can do it from code, but you have to muck about in the registry: http://mel-green.com/2009/04/c-set-file-type-association/
您询问如何 将文件类型与您的应用程序关联起来。您可以通过使用 C# 将条目添加到注册表来完成此操作。
You're asking how to associate a file type with your application. You can do this by adding entries to the registry using C#.