Zayko in the Net

Personal blog of Vitaly Zayko

NAVIGATION - SEARCH

How to open file by associated program? (C#)

If you are familiar with Win32 API then you should know function ShellExecute which performs some operations on files including opening in programs associated with this particular file type.

In .NET Framework world you can use this function through PInvoke but there is a managed mechanism to do the same:

using (System.Diagnostics.Process prc = new System.Diagnostics.Process())
{
   prc.StartInfo.FileName = "c:\\test.txt";
   prc.Start();
}

Enjoy!

Add comment