I wish add debug code check that an image exits (to help catch bugs when an image is not added to the project properly) - how would i do this?
ImageSource.FromFile("myImage.png") does not give any functions to help with this?
You can loop over the available resources. Here's a stack overflow article describing how: http://stackoverflow.com/questions/2041000/loop-through-all-the-resources-in-a-resx-file
@Josh_Quintus - that does not seam compatible with Forms - i need to know if a file is in the android & iOS resource files structure - i want to read this from forms code (not from platform specific code)
string resourceNames = this.GetType().GetTypeInfo().Assembly.GetManifestResourceNames();
foreach (var name in resourceNames)
// do something with Name
This is specifically discussed in the Working with Files doc, although please note that is referring to files (including images) that have been added as embedded resources.
That does not apply when using FromFile since that loads images from the platform-specific app. See the Working with Images doc for more info. You're right that there are no additional functions (like 'Exists') to help determine whether an image is there, unfortunately.
Hmm, a more roundabout way of doing it is to wrap it in a try/catch block, and handle the exception. Maybe that works.
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies