A similar answer to the one accepted above, but I wanted to share my solution in VB.NET.
''' <summary> ''' Gets the file name in its proper case as found in the assembly. ''' </summary> ''' <param name="fileName">The filename to check</param> ''' <param name="assemblyNamespace">The namespace name, such as Prism.Common</param> ''' <param name="assembly">The assembly to search</param> ''' <returns>The file name as found in the assembly in its proper case, otherwise just filename as it is passed in.</returns> ''' <remarks></remarks> Public Shared Function GetProperFileNameCaseInAssembly(ByVal fileName As String, ByVal assemblyNamespace As String, ByVal assembly As System.Reflection.Assembly) As String For Each resource As String In assembly.GetManifestResourceNames() 'Perform a case insensitive search to get the correct casing for the filename If (resource.ToLower().Equals(String.Format("{0}.{1}", assemblyNamespace, fileName).ToLower())) Then 'cut off the namespace assembly name in the resource (length + 1 to include the ".") to return the file name Return resource.Substring(assemblyNamespace.Length + 1) End If Next Return fileName 'couldn't find the equivalent, so just return the same file name passed in End Function
source share