Reputation: 12814
In VB.Net, I can retrieve my application's ProductName and CompanyName by using:
My.Application.Info.ProductName
My.Application.Info.CompanyName
How do I do the same thing in C#?
Upvotes: 20
Views: 21780
Reputation: 2320
You can use Assembly
and FileVersionInfo
Assembly assembly = Assembly.GetExecutingAssembly();
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
var companyName = fvi.CompanyName;
var productName = fvi.ProductName;
var productVersion = fvi.ProductVersion;
Upvotes: 61
Reputation: 1
var company = new AssemblyInfo(Assembly.GetExecutingAssembly()).CompanyName;
Second usage:
var codedBy = var company = "Coded by "+(new AssemblyInfo(Assembly.GetExecutingAssembly()).CompanyName);
Upvotes: 0
Reputation: 3738
Just use:
System.Windows.Forms.Application.ProductName
System.Windows.Forms.Application.CompanyName
...in assembly System.Windows.Forms.dll
Or if you prefer:
using System.Windows.Forms;
//...
string productName = Application.ProductName;
string companyName = Application.CompanyName;
Upvotes: 11
Reputation: 21881
You need to reference the Microsoft.VisualBasic.MyServices
namespace. See this for more info. You can't use the exact same syntax though. There are also more general .net ways that you would normally use in c# to get the same kind of info you get from My.Whatever in VB but they are completely unrelated to each other. There is no direct equivalent of using My.Whatever in c# the language.
Upvotes: 2