-2

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.

Moh3en
  • 1
  • 2
  • File associations are set in the registry as seen here: http://stackoverflow.com/questions/2681878/associate-file-extension-with-application – bwoogie Feb 11 '17 at 21:11

1 Answers1

-1

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

CodingYoshi
  • 25,467
  • 4
  • 62
  • 64
  • I did it by mp3 did not played.just program opend as useul – Moh3en Feb 12 '17 at 12:15
  • From the sounds of OP's comment, I believe it's not a duplicate of https://stackoverflow.com/questions/2681878/associate-file-extension-with-application. It seems likely that OP's program is not reading parameters from the command-line correctly since it does open. [code] static void Main(string[] args) – ErrCode Aug 09 '17 at 01:00
  • Oops. Exceeded the time limit for fixing my comment above. @Moh3en: you're app probably just needs to handle command line arguments. Here's some quasi code: static void Main(string[] args) { string mp3File = null; if (args.Length > 0) mp3File = args[0]; // do something with your mp3File.. } Alternatively you could also use `Environment.GetCommandLineArgs()` as shown here (just keep in mind that the first value in the array is the executable itself): https://stackoverflow.com/a/18448925/7270462 – ErrCode Aug 09 '17 at 01:12