Click here to Skip to main content
15,887,821 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted

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[^].
 
Share this answer
 
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:
C#
string[] args = Environment.GetCommandLineArgs();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900