NETMF provides two methods to retrieve resources using the type Microsoft.SPOT.ResourceUtility and precisely:
public static object GetObject(System.Resources.ResourceManager rm, Enum id) and
public static object GetObject(System.Resources.ResourceManager rm, Enum id, int offset, int length);
Both methods allow retrieving binary resources as well as bitmaps and so on..., where the second method allows retrieving binary resources in chunks.
You can also accomplish the same task by using the code auto-generated by the resource designer. See the HttpClient sample for a usage example, also reported below:
namespace HttpClientSample
{
public static class MyHttpClient
{
/// <summary>
/// Retrieves a page from a Web server, using a simple GET request.
/// </summary>
public static void Main()
{
Microsoft.SPOT.Hardware.Utility.SetLocalTime(new DateTime(2011, 4, 14));
// Wait for DHCP (on LWIP devices)
while (true)
{
IPAddress ip = IPAddress.GetDefaultLocalAddress();
if (ip != IPAddress.Any) break;
Thread.Sleep(1000);
}
// Root CA Certificate needed to validate HTTPS servers.
byte[] ca = Resource1.GetBytes(
Resource1.BinaryResources.VerisignCA);
X509Certificate[] caCerts =
new X509Certificate[] { new X509Certificate(ca) };
...
To attach a resource as a binary resource to your NETMF application, you need to give your resource a neutral extension, such as .bin. If you try to attach a bitmap as a binary resource and your file as a .bmp extension, then the resource generator will treat it as a bitmap.
Regards