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#?
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;
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;
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With