Run an app or a link
April 11, 2009
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.GetExecutingAssembly. To get assembly in which the specified class is defined use method Assembly.GetAssembly (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/
Leave a Reply