C# 将我的应用程序设置为默认应用程序
我是一名新手程序员,并根据自己的需要开发了一个记事本替换应用程序(具有更多功能)。当我双击 .txt 文件(或可自定义的扩展名,例如 .abc)时,我希望该文件像记事本一样在我的应用程序中运行。我读到了有关程序的文件关联的内容,但我没有得到太多内容。
有人能指出我该怎么做吗?请给我一些想法,我真的很想这样做,并为我的用户提供一个将应用程序设置为默认文本编辑器的选项。非常感谢您的帮助。
I'm a novice programmer and have developed a notepad replacement application for my own needs (with some more features). When I double click a .txt file (or a customizable extension such as .abc), I want the file to run in my application just like notepad. I read about File Association with programs but I didn't get much of it.
Can someone point me to how I would do this? Just give me a few ideas, I would really like to do this and have an option for my users to set the application as the default text editor. Help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看看这里:如何强制使用我的程序打开某种类型的任何文件?
Have a look here: how to force that any file of a certain type will open with my program?
如果您使用单击一次部署(即在 VS 中“发布”Windows exe),您可以在那里指定文件关联,它会为您完成所有操作。不过,我不能保证它会优先于记事本。为此,您可能需要一个合适的安装程序...
MSDN显示如何实现
If you are using click-once deployment (i.e. "publish" in VS for a windows exe), you can specify file associations there, and it will do everything for you. I can't guarantee that it'll take precedence over notepad, though. For that you might need a proper installer...
MSDN shows how
就这样吧
There you go