- Only for .NET assembly
System.Reflection.Assembly AssemblyFileInfo = System.Reflection.Assembly.Load(FileAppPath);
Console.WriteLine (AssemblyFileInfo.GetName().Version); - For all .NET and native assembly
FileVersionInfo AssemblyFileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(FileAppPath);
Console.WriteLine(AssemblyFileVersion.FileVersion)
Visualizzazione post con etichetta Reflection. Mostra tutti i post
Visualizzazione post con etichetta Reflection. Mostra tutti i post
giovedì 9 luglio 2009
Get the version information of an extern assembly
We have more ways to get the information of an assembly, the most two I use are:
Etichette:
Assembly,
c#,
FileInfo,
FileVersion,
Reflection
martedì 9 giugno 2009
Application Path
Sometime I need to retrieve the application path, here I add the four methods I use frequently.
- The simple way through windows forms:
using System.Windows.Forms;
String sAppPath1 = Application.StartupPath; - From the binary over reflection:
String sAppPath2 = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase ); - Using the file informations:
FileInfo executableFileInfo = new FileInfo (Application.ExecutablePath);
String sAppPath3 = executableFileInfo.DirectoryName; - When my program is started from another:
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
Iscriviti a:
Post (Atom)