+ 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#]
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
+ 3
Find program.cs in solution explorer. You can find Main method. Add string[] args as parameter,
Use try{ if(args[0] != null)} catch{}
+ 2
Opendialog is a standard component.
Have a look at these links.
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.openfiledialog?view=netcore-3.1
https://www.c-sharpcorner.com/UploadFile/mahesh/openfiledialog-in-C-Sharp/
https://www.dotnetperls.com/openfiledialog
+ 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]
+ 1
hossein B ok thanks
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]