how do I read a files' or assemblys' metadata (date modified, assembly version, etc.)
-
Hi, i've tried 'google'ing to find any article on how i might be able to read the metadata of a file or .net 2.0 rc1 assembly that i've built (e.g. the date the file was last modified, or the author of the assembly, it's version etc), but i seem to have hit a bit of a brick wall, i'm sure there must be a simple (or not) way to read this kind of information about a file programmtically. any help or nudges in the right direction will be greatly appreciated:) Thanks in advance. Afzal "AV-E" Hassen
-
Hi, i've tried 'google'ing to find any article on how i might be able to read the metadata of a file or .net 2.0 rc1 assembly that i've built (e.g. the date the file was last modified, or the author of the assembly, it's version etc), but i seem to have hit a bit of a brick wall, i'm sure there must be a simple (or not) way to read this kind of information about a file programmtically. any help or nudges in the right direction will be greatly appreciated:) Thanks in advance. Afzal "AV-E" Hassen
I'm not sure if it will give you all the info you need, but you can do: Assembly asm = Assembly.Load(filename); then use properties/methods of asm: asm.GetName().Version You can also get attributes of an assembly by using GetCustomAttributes(typeof(AssemblyTitleAttribute), true)
-
Hi, i've tried 'google'ing to find any article on how i might be able to read the metadata of a file or .net 2.0 rc1 assembly that i've built (e.g. the date the file was last modified, or the author of the assembly, it's version etc), but i seem to have hit a bit of a brick wall, i'm sure there must be a simple (or not) way to read this kind of information about a file programmtically. any help or nudges in the right direction will be greatly appreciated:) Thanks in advance. Afzal "AV-E" Hassen
Try this... using System; using System.IO; using System.Reflection; public class Meta { public static int Main( ) { // First load the assembly. Assembly a = Assembly.LoadFrom("hello.exe"); // Get all the modules that the assembly supports. Module[] m = a.GetModules( ); // Get all the types in the first module. Type[] types = m[0].GetTypes( ); // Inspect the first type. Type type = types[0]; Console.WriteLine("Type [{0}] has these methods:", type.Name); // Inspect the methods supported by this type. MethodInfo[] mInfo = type.GetMethods( ); foreach ( MethodInfo mi in mInfo ) { Console.WriteLine(" {0}", mi); } return 0; } } ;)
-
Try this... using System; using System.IO; using System.Reflection; public class Meta { public static int Main( ) { // First load the assembly. Assembly a = Assembly.LoadFrom("hello.exe"); // Get all the modules that the assembly supports. Module[] m = a.GetModules( ); // Get all the types in the first module. Type[] types = m[0].GetTypes( ); // Inspect the first type. Type type = types[0]; Console.WriteLine("Type [{0}] has these methods:", type.Name); // Inspect the methods supported by this type. MethodInfo[] mInfo = type.GetMethods( ); foreach ( MethodInfo mi in mInfo ) { Console.WriteLine(" {0}", mi); } return 0; } } ;)
Thanks guys. i'll give it a shot :) Afzal "AV-E" Hassen