-
September 24th, 2007, 01:59 AM
#1
how do you find out what the name of your app is
What is the function that let you know what the name of your App (.exe) is and from where it is being run from ?
cheers
-
September 24th, 2007, 03:38 AM
#2
Re: how do you find out what the name of your app is
If you have defined the application name in your AssemblyInfo.cs you can read the application name by using the following code.
Code:
private string AssemblyTitle
{
get
{
// Get all Title attributes on this assembly
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
// If there is at least one Title attribute
if (attributes.Length > 0)
{
// Select the first one
AssemblyTitleAttribute titleAttribute = (AssemblyTitleAttribute)attributes[0];
// If it is not an empty string, return it
if (titleAttribute.Title != "")
return titleAttribute.Title;
}
// If there was no Title attribute, or if the Title attribute was the empty string, return the .exe name
return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
}
}
And this should give you the right location.
Code:
string location = Assembly.GetExecutingAssembly().Location;
Useful or not? Rate my posting. Thanks.
-
September 24th, 2007, 04:24 AM
#3
Re: how do you find out what the name of your app is
Assuming that you're running a Windows Forms app use Application.ExecutablePath and Application.StartupPath.
-
September 24th, 2007, 08:02 PM
#4
Re: how do you find out what the name of your app is
Yea thanks
but what do i have to include on top of the file
Error 1 The name 'Assembly' does not exist in the current context ?
Cheers
-
September 24th, 2007, 08:09 PM
#5
Re: how do you find out what the name of your app is
Include
Code:
using System.Reflection;
-
September 24th, 2007, 10:11 PM
#6
Re: how do you find out what the name of your app is
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
|