Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I have created a simple notepad application.
I have deployed it in my system by creating setup file for that app.
But , only one problem is that

generally we open a file in this way
 

right click a file -> open with -> choose the program with which we want to open the file.
 

then the file will be loaded into the richtextBox field provided in the app.
 
Can any one suggest me what is the code i have to add to get the file loaded as we open the file?????
Posted 13-Dec-12 8:52am
Comments
jibesh at 13-Dec-12 16:21pm
   
Your question is not clear. where you are stuck?
dont know how to read a file ?
what type of file is that?
what are all the extensions your application does support?
 
"generally we open a file in this way
right click a file -> open with -> choose the program with which we want to open the file."
 
Not necessarily .. I double click on the file at times and it loads on the editor associated with that file extension
Sergey Alexandrovich Kryukov at 13-Dec-12 17:16pm
   
You considerations about "right click a file" make me think that this is off-topic. This is a forum for software developers. From programmatic standpoint, you don't "click a file", like a (possibly lamer) user... :-)
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

This is System.Windows.Forms.RichTextBox.LoadFile: http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.loadfile.aspx[^].
 
—SA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

System.Windows.Forms.RichTextBox.LoadFile(FileName, RichTextBoxStreamType);
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

To make this right-click-open-with-approach work, you need to process command-line parameters to your program. If it has been called by the operating system with the intent to open a file, the OS will
1. have called your executable and
2. have appended the path to the file as parameter.
 
Use the Environment.GetCommandLineArgs()[^] method to get all the arguments that your executable has been called with and check if the first one is a file that you can open. If so, then open it just like you would do after user clicks File - Open - [filename] from within your application.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

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



Advertise | Privacy | Mobile
Web02 | 2.8.141022.2 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100