WPF - resource check exists without handling structured exceptions

Is there a way to check if a resource exists in an assembly without using exception handling? I am currently loading images from several assemblies, and if they do not exist, then I am handling an IOException, which causes quite a bit of overhead.

+4
source share
1 answer

Something like this work for you?

// Member Variable string [] resourceNames; // Function Boolean ResourceExists(string resourceName) { if (resourceNames == null) { resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames(); } return resourceNames.Contains(resourceName); } 
+6
source

Source: https://habr.com/ru/post/969460/


All Articles