How to Default a program using c# [duplicate] - c#

This question already has answers here:
Associate File Extension with Application
(9 answers)
Closed 6 years ago.
I created a media player in winforms.i want to default it using c#.when you clicked an mp3 anywhere ,windows media player open that mp3file.i want to my program open files when double clicked on a mp3 or other files.
I hope someone helps me.

Right click an MP3 file > Open With > Choose Default Program and then choose your application by browsing to the .exe file of your application.

Related

How to "pull" an existing pdf into the app? [duplicate]

This question already has answers here:
Display a PDF in WPF Application [closed]
(9 answers)
Closed 3 years ago.
I currently have an app in C#/WPF, and I have a manual on how to use it in pdf, and I'm thinking of adding a button that when clicked open the manual ... How can I do this?
Process.Start("C:\Temp\yourname.pdf");
replace the string "C:\Temp\yourname.pdf" with the path and filename for the pdf file you want to open.
This will cause the pdf to open in your systems default pdf application.
You will need: - using System.Diagnostics;

How I can play audio in C# console application? [duplicate]

This question already has answers here:
How to play a sound in C#, .NET
(7 answers)
Closed 3 years ago.
I would like to know if it possible just play some kind of audio file in C# Console Application.
I don't find any answer on this question.
Many Thanks
In command prompt you can play an audio file by typing it's name from location folder:
c:\my_Music>track1.mp3
This opens the file with the format's associated progam so there will be a pop-up of an external program. Set program by using right-click on a file and choose "Open With".
I've not tested this in a console app. But you should be able to type a String into the console app and then trigger an ENTER press event.
Option 2:
Use SoundPlayer class.
A good tutorial for beginners. Also can check this: Playing sounds on Console.

Opening A File With Code [duplicate]

This question already has answers here:
Open file with associated application
(3 answers)
Closed 5 years ago.
I have a string of the file path and I want to open the file. Not in the way that it shows bytes in the console for example, but to open the original file with the program that suits him.
For example if my path shows a .docs file I want it to be opened with Word.
Any suggestions?
System.Diagnostics.Process.Start("CMD.exe",filePath);

How to make file to be opened by my app? [duplicate]

This question already has answers here:
Where does Windows store its "Open With" settings?
(3 answers)
Closed 9 years ago.
I have a little bit confusing problem. I'm not a beginner but I don't know how to do it..
For example I've written a program like notepad from which you can open files, save and etc. But when I set any custom format like ".blabla" to be opened by my app it is not working, so how can I make it to be opened by my app?
It is in WinForms
You need an entry in the registry for custom file extensions. You can try inserting a key in the registry as follows:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\

C# class similar to Java Desktop class [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Open file with associated application
I want to open a file in it respective application, e.g. open function of windows.
Same thing can be done in java with the help of Desktop class where you pass the file name and the respective file is opened.
But no idea how to do in C#.
System.Diagnostics.Process.Start("filename.doc");

Categories