-
July 13th, 2005, 08:19 AM
#1
get the Current Application Name
Hi EveryBody,
How we get the Current Application Name using C# at run time ..Guide me
Regards
M.Suresh
-
July 13th, 2005, 08:32 AM
#2
Re: get the Current Application Name
Try
Code:
string name = System.Reflection.Assembly.GetEntryAssembly().FullName;
Last edited by torrud; July 13th, 2005 at 08:34 AM.
Useful or not? Rate my posting. Thanks.
-
July 13th, 2005, 08:36 AM
#3
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 08:56 AM.
Can you help me with my homework assignment?, Before you post!, Use code tags, How to post!, Codeguru technical FAQs, C++ FAQ Lite, Stroustrup: C++ Style and Technique FAQ, Guru of the Week, Comeau C and C++ FAQs, Comeau C++ Templates FAQs, CUJ @ DDJ, Spam threshold
My Blogs : Learning C++ is fun | Abnegator's reflections
Open Threads : C++ Aha! Moments | Nature of work in C++?
-
July 13th, 2005, 08:40 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|