![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How does one get the application name of a C# program at runtime Hi, How do I get the application name during run time. In C or C++ I use argv[0], but in C# args[0] contains the first argument to the program not the program name. So, what is the magic to getting this? Thanks, Andy |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How does one get the application name of a C# program at runtime Andrew Falanga wrote: Quote: > How do I get the application name during run time. In C or C++ I use > argv[0], but in C# args[0] contains the first argument to the program > not the program name. So, what is the magic to getting this? > -- J. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How does one get the application name of a C# program at runtime Andrew Falanga <af300wsm@xxxxxx> wrote: Quote: > How do I get the application name during run time. In C or C++ I use > argv[0], but in C# args[0] contains the first argument to the program > not the program name. So, what is the magic to getting this? but it works for console apps too. -- Jon Skeet - <skeet@xxxxxx> Web site: http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet C# in Depth: http://csharpindepth.com |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How does one get the application name of a C# program at runtime "Andrew Falanga" <af300wsm@xxxxxx> wrote in message news:27a7bd0f-b021-47b4-bafe-f106c78dd51b@xxxxxx Quote: > Hi, > > How do I get the application name during run time. In C or C++ I use > argv[0], but in C# args[0] contains the first argument to the program > not the program name. So, what is the magic to getting this? There may be an easier way, but this works: String thismodulefilenamestr = System.IO.Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); Mark -- Mark Salsbery Microsoft MVP - Visual C++ Quote: > > Thanks, > Andy |
My System Specs![]() |
| | #5 (permalink) |
| | Re: How does one get the application name of a C# program at runtime "Andrew Falanga" <af300wsm@xxxxxx> wrote in message news:27a7bd0f-b021-47b4-bafe-f106c78dd51b@xxxxxx Quote: > Hi, > > How do I get the application name during run time. In C or C++ I use > argv[0], but in C# args[0] contains the first argument to the program > not the program name. So, what is the magic to getting this? Here's another one String thismodulefilenamestr = System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location); Mark -- Mark Salsbery Microsoft MVP - Visual C++ Quote: > > Thanks, > Andy |
My System Specs![]() |
| | #6 (permalink) |
| | Re: How does one get the application name of a C# program at runtime Jon Skeet [C# MVP] wrote: Quote: > Andrew Falanga <af300wsm@xxxxxx> wrote: Quote: >> How do I get the application name during run time. In C or C++ I use >> argv[0], but in C# args[0] contains the first argument to the program >> not the program name. So, what is the magic to getting this? > You can use Application.ExecutablePath - it's in System.Windows.Forms, > but it works for console apps too. new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath (Application.ExecutablePath is much easier though) Alun Harford |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Visual studio 2008 IDE application R6034 runtime error - MSDN news group moderator Please Respond. | .NET General | |||
| Runtime Error (abnormal program termination) | General Discussion | |||
| runtime error 2147221018 (800-401e6) No program registered toopen | Vista General | |||
| application causing runtime error | Vista performance & maintenance | |||