Run an app or a link


April 11, 2009
Don't know what to read next? Check out the list of popular posts. People like them, they should be good.

another tip »

To run an app or a link(open in default browser)

System.Diagnostics.Process.Start("http://www.hieu.co.uk/");

Or even email:

System.Diagnostics.Process.Start("mailto:hieuuk@gmail.com");

Or for app and more complex path:

System.Diagnostics.Process vlc	= new System.Diagnostics.Process();
notePad.StartInfo.FileName	= "vlc.exe";
notePad.StartInfo.Arguments	= "xmen.avi";
notePad.Start();

First get reference to the assembly. You can use static methods of Assembly class. To get assembly of currently executing code use method Assembly.GetE­xecutingAssem­bly. To get assembly in which the specified class is defined use method Assembly.GetAs­sembly (with the specified class type as a paramater). The assembly must be loaded. Next get assembly file path using Assembly.CodeBase property.

using System.IO;
using System.Reflection;

string path = Assembly.GetAssembly(typeof(MyClass)).CodeBase;

http://www.csharp-examples.net/get-application-directory/

  • Delicious

Some more useful articles for you

Under Category: C#.NET Code
Article Tags: ,
Leave a Reply