Is there any way to check if a resource exists in an assembly without having to use exception handling? I'm currently loading images from several assemblies, and if they don't exist then I'm handling the IOException, which causes quite a bit of overhead.
Would 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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With