Retrieving Icons Embedded in Assemblies
-
I am working on an application and need to be able to have the application have the ability to "look into" an assembly and list out the icons which are compiled into it. Any points into the right direction would be greatly appreciated. :) Happy Programming and may God bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp N-Tech Productions http://www.n-tp.com/
-
I am working on an application and need to be able to have the application have the ability to "look into" an assembly and list out the icons which are compiled into it. Any points into the right direction would be greatly appreciated. :) Happy Programming and may God bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp N-Tech Productions http://www.n-tp.com/
All embedded icons will turn up as resources in the assembly with the .ico extension. The only tricky bit is that VS.Net adds the DefaultNamespace to the front of the icon file name when it compiles the assembly so you have to chop that off. Here is an example showing how you would do this using the current assembly, and display the list in a messagebox. To run on another assembly simply use Assembly.LoadFrom() to get a pointer to it.
Dim TestAssembly As \[Assembly\] = System.Reflection.Assembly.GetExecutingAssembly Dim namesList As String() = TestAssembly.GetManifestResourceNames ' Fudge to get the default Namespace for the assembly. Dim currentNameSpace As String = \[String\].Empty currentNameSpace = TestAssembly.GetTypes(0).Namespace If currentNameSpace.Length > 0 Then currentNameSpace &= "." End If Dim list As String = \[String\].Empty Dim names As IEnumerator = namesList.GetEnumerator While names.MoveNext If names.Current.ToString().ToLower().EndsWith(".ico") Then list &= names.Current.ToString().Replace(currentNameSpace, "") & System.Environment.NewLine End If End While MessageBox.Show(list)
If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850)
-
All embedded icons will turn up as resources in the assembly with the .ico extension. The only tricky bit is that VS.Net adds the DefaultNamespace to the front of the icon file name when it compiles the assembly so you have to chop that off. Here is an example showing how you would do this using the current assembly, and display the list in a messagebox. To run on another assembly simply use Assembly.LoadFrom() to get a pointer to it.
Dim TestAssembly As \[Assembly\] = System.Reflection.Assembly.GetExecutingAssembly Dim namesList As String() = TestAssembly.GetManifestResourceNames ' Fudge to get the default Namespace for the assembly. Dim currentNameSpace As String = \[String\].Empty currentNameSpace = TestAssembly.GetTypes(0).Namespace If currentNameSpace.Length > 0 Then currentNameSpace &= "." End If Dim list As String = \[String\].Empty Dim names As IEnumerator = namesList.GetEnumerator While names.MoveNext If names.Current.ToString().ToLower().EndsWith(".ico") Then list &= names.Current.ToString().Replace(currentNameSpace, "") & System.Environment.NewLine End If End While MessageBox.Show(list)
If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850)
Thanks for the help! :) Happy Programming and may God bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp N-Tech Productions http://www.n-tp.com/