双击文件打开程序,如何在C#中实现 [英] double click on file opens program, how to implement in c#

查看:125
本文介绍了双击文件打开程序,如何在C#中实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,在安装程序时,您可以单击该类型的文件,该文件将在该程序中打开.

例如,在Excel中,单击.xls文件,然后Excel启动并打开程序.

我知道文件关联(例如.xls是Excel)将由安装程序完成.

在C#中,如何打开和显示文件?我假设在这种情况下有一种方法被调用?

Usually when a program in installed, you can click on a file of that type and the file will open in the program.

For example, in Excel, you click on an .xls file, and Excel boots up and opens the program.

I know the file association (e.g. .xls is Excel) would be done by an installer.

In C#, how does the file get opened and displayed? I presume there is a method that is called in such situations?

推荐答案

您必须将文件扩展名与应用程序关联.您可以在安装项目中执行此操作. Google是您的朋友.

提醒您-您可能应该尝试确保文件扩展名是唯一的.如果您为扩展名使用三个以上的字母,那么您将为此感到更幸运.例如,使用".txt123"代替".txt".
You have to associate the file extension with the application. You can do this in your setup project. Google is your friend.

Word of caution - you should probably try to ensure that your file extension is unique. You will have more luck with this if you use more than three letters for the extension. For example, instead of ".txt", use ".txt123".


这篇关于双击文件打开程序,如何在C#中实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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