+ 2

Open with in c# windows forms

Last night I was created a windows from application it works is similar to notepad and I want to make it can open files from windows openwith dialog how to create it? [In c#]

18th Oct 2020, 1:41 PM
Martin Jefferson
Martin Jefferson - avatar
6 Antworten
+ 3
The Open With command just passes the path of the file as the first argument to the application so all you need to do is public static void Main(string[] args) { if(args[0] != null) { //args[0] contans a path to the file do whatever you need to do to display it } else { //Start normally } } To automaticly put your program in the open with list you will need to add some reg keys in HKEY_CLASSES_ROOT\YOUR_EXT\ or use advanced installer. This app helps you to add your program to open with menu
22nd Oct 2020, 10:00 PM
hossein B
hossein B - avatar
+ 3
Find program.cs in solution explorer. You can find Main method. Add string[] args as parameter, Use try{ if(args[0] != null)} catch{}
25th Oct 2020, 7:48 AM
hossein B
hossein B - avatar
+ 1
hossein B how to do it in windows forms? I think we can do it in main.cs file //I and you are from one //country [Iran]
25th Oct 2020, 6:43 AM
Martin Jefferson
Martin Jefferson - avatar
+ 1
hossein B ok thanks
25th Oct 2020, 11:14 AM
Martin Jefferson
Martin Jefferson - avatar
0
sneeze I know it so I want to do it on the windows explorer [If you right click on a txt file and select [open with>] you will be able to open a file with multiple programs ] I want to insert my app into that list [File assignment]
19th Oct 2020, 7:36 AM
Martin Jefferson
Martin Jefferson - avatar