get the Current Application Name
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: get the Current Application Name

  1. #1
    Join Date
    Dec 2004
    Posts
    25

    get the Current Application Name

    Hi EveryBody,


    How we get the Current Application Name using C# at run time ..Guide me


    Regards
    M.Suresh

  2. #2
    Join Date
    May 2003
    Location
    Germany
    Posts
    936

    Re: get the Current Application Name

    Try
    Code:
    string name = System.Reflection.Assembly.GetEntryAssembly().FullName;
    Last edited by torrud; July 13th, 2005 at 09:34 AM.
    Useful or not? Rate my posting. Thanks.

  3. #3
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

    Thumbs up Re: get the Current Application Name

    What kind of application is it?

    Have you defined the various parameters in the AssemblyInfo.cs file? If yes you could use this method as stated by Darwen.

    If its a console application use:
    Code:
    static void Main(string[] args)
    {
         //Environment.GetCommandLineArgs() requires EnvironmentPermissionAccess.Read
         Console.WriteLine (Environment.GetCommandLineArgs()[0]);
    }
    There are other ways of doing this. See if the following work: (I found it on the google search, haven't tested)
    1. In WinForms - Application.ExecutablePath - requires FileIOPermissionAccess.PathDiscovery
    2. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName - SecurityPermission for calling any members of System.Diagnostic.Process with full trust (which you might have problems with) . Associated enumeration: PermissionState.Unrestricted
    3. Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName

    By the way, I dont get what you want out of this. Its going to be your application. You would always be knowing the name. You could simply hardcode it somewhere or make a constant somewhere. Could even store the name in your web.config (if its a APS.Net project) under appSetting and get the key value from there. I didnt quite get what you are trying to achieve here.
    Last edited by exterminator; July 13th, 2005 at 09:56 AM.

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: get the Current Application Name

    This might help
    Code:
    MessageBox.Show(Application.ProductName.ToString());

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center