如何打开文本文件。 [英] How to open a text file.

查看:112
本文介绍了如何打开文本文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在开发一个文本编辑器。

如何使用我的文本编辑器双击该文件来打开文本文件。

我有尝试在Windows中使用打开方式,但它只打开我的文本编辑器,但不打开文本文件中的内容。

请给我一个解决方案。

Currently I'm developing a "text editor".
How can I open a text file by double click on that file using my text editor.
I have tried using "open with" in windows but it only opens my text editor but not the content in text file.
Please give me a solution.

推荐答案

如果希望在双击文本文件时启动编辑器,则需要在Windows资源管理器中修改文件类型。或者,您可以通过编程方式将参数添加到注册表中:请参阅 https:// www.google.com/search?q=associate+file+type+with+program+c%23 [ ^ ]。
If you want your editor to be started whenever a text file is double clicked then you need to modify the file type in Windows Explorer. Alternatively you can add the parameters to the registry programmatically: see https://www.google.com/search?q=associate+file+type+with+program+c%23[^].


多种方式:

http://msdn.microsoft.com/en-us/library /db5x7c0d(v=vs.110).aspx [ ^ ]



http://msdn.microsoft.com/en-us/library/ezwyzy7b.aspx [ ^ ]



http://www.homeandlearn.co.uk/csharp/csharp_s11p1.html [ ^ ]



谷歌是你最好的朋友。
Many ways:
http://msdn.microsoft.com/en-us/library/db5x7c0d(v=vs.110).aspx[^]

http://msdn.microsoft.com/en-us/library/ezwyzy7b.aspx[^]

http://www.homeandlearn.co.uk/csharp/csharp_s11p1.html[^]

Google is your best friend.


你使用打开方式文件的路径作为程序参数交给你 - 所以如果你正在编写一个控制台应用程序,那么你将通过 args 参数获得它到 Main 方法。

对于winforms应用程序,最简单的方法是通过环境获取它们:

When you use "open with" the path to the file is handed to you as a program argument - so if you are writing a Console app then you would get it via the args parameter to the Main method.
For a winforms app it is easiest to get them via the Environment:
string[] args = Environment.GetCommandLineArgs();


这篇关于如何打开文本文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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