0

I would need my app to just run any file in a player/browser that Windows use (so for AVI it would use e.g. BSPlayer or whatever has the PC set etc.). All I found was related to EXE files.

EDIT: I do not mean just multimedia files. I mean also TXT (where I would expect Notepad to open etc.)

John V
  • 4,855
  • 15
  • 39
  • 63

3 Answers3

3

Use Process.Start(System.String) to start the default application for a file type.

For example:

Process.Start(@"C:\MyFile.txt");

Or

Process.Start(@"D:\Videos\Films\SomeFilm.avi");
Lukazoid
  • 19,016
  • 3
  • 62
  • 85
0

You can use DirectX for that.

From the MSDN forum

//create the video
Microsoft.DirectX.AudioVideoPlayback.Video video = new Microsoft.DirectX.AudioVideoPlayback.Video(fileName);
//set the System.Windows.Forms.Control to play it in (e.g a panel)
video.Owner = panel1;
//Play the video (put this in a buttons click event)
video.Play();
//Pause the video (put this in a buttons click event)
video.Pause();
//Stop the video (put this in a buttons click event)
video.Stop();

Also check Playing Audio and Video Files Using C#

EDIT:

You may try this:

System.Diagnostics.Process.Start(@"yourfilewith a path");

to start the application.

A sample example:

String fileToOpen = "C:/test.avi";
System.Diagnostics.ProcessStartInfo ps = new System.Diagnostics.ProcessStartInfo("C:/Program Files/Windows Media Player/wmplayer.exe", fileToOpen);
System.Diagnostics.Process.Start(ps);
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
0

If it's a console/windows application best to use

 System.Diagnostics.Process.Start("your file path and file extension");
Chandan Kumar
  • 4,570
  • 4
  • 42
  • 62