Byte [] data = Resources.GetBytes(Resources.BinaryResources.Sample); Object data = Microsoft.SPOT.ResourceUtility.GetObject(Resources.ResourceManager, Resources.BinaryResources.Sample); Stream data = (Stream)Microsoft.SPOT.ResourceUtility.GetObject(Resources.ResourceManager, Resources.BinaryResources.Sample);The first isn't too surprising, the second maybe a little more so, but the third is a bit disappointing. It looks like there's a "GetManifestResourceStream" method in the Assembly class on most C# implementations that would be useful, but for some reason isn't available on this particular build of NETMF. Thoughts? Chris, was this intentionally omitted to save space? Thanks.
Reading binary resources piecemeal
#1
Posted 07 November 2010 - 07:05 PM
#2
Posted 07 November 2010 - 07:24 PM
#3
Posted 08 November 2010 - 08:53 AM
#4
Posted 15 November 2011 - 06:33 PM
NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and down - and upload files
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
#5
Posted 15 November 2011 - 07:36 PM
.NET MF version 4.2 introduces a method for partial reading of binary resources, there is a new overload of Resources.GetObject(..., int offset, int length).Has there been a solution on this problem?
#6
Posted 15 November 2011 - 08:32 PM
StringBuilder and this piece of code would really help...
Do you know how to use it exactly?
What does it return? If Resources.GetObject(..., int offset, int length) is an object, can I just cast it to String without any problems? In case i have a .txt embedded ressource that has 10 kb, and I want to load it in 10 pieces a 1 kb, can i use string
part1 = (String)Resources.GetObject(...,0,1000)?
Greets, Markus
NeonMika.Webserver
> Control your N+ and write webservice methods easyily
> Receive data from you N+ (in XML or JSON)
> Browse the SD on your N+ directly in the browser and down - and upload files
If you need help with NeonMika.Webserver, please just leave a note in the thread and/or contact me via Skype
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Mistakes teach you important lessons. Every time you make one, you are one step closer to your goal. ----
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
#7
Posted 19 December 2011 - 09:36 PM
.NET MF version 4.2 introduces a method for partial reading of binary resources, there is a new overload of Resources.GetObject(..., int offset, int length).
Hello,
What references and namespace I must use to have acess to Resources class? I have already upgraded my device and project o .net mf 4.2 and only ResourceManager class is available on Resources namespace.
Thank you,
Igor.
Please do not consider this message. I notice that my project still did not have any resources created... my bad.
Edited by Igor Kondrasovas, 19 December 2011 - 09:45 PM.
Igor Kondrasovas
www.inovativatec.com
#8
Posted 20 December 2011 - 12:06 PM
.NET MF version 4.2 introduces a method for partial reading of binary resources, there is a new overload of Resources.GetObject(..., int offset, int length).
I am curently testing this GetObject overload, and I am experiencing an strange behaviour.
1 - I created a binary file called "sm.bin", witch is attached to this message (zipped in this message so I could not upload .bin files). It is a very small file with 8 bytes on it.
2 - Then I added this bin file to my resources in my net mf project. Build Action = embedded resource and always copy to output
3 - In the very beginning of main method, I used
byte[] data = (byte[])ResourceUtility.GetObject(Resources.ResourceManager, Resources.BinaryResources.sm, 0, 8);When I run the code, data contains 0 bytes.
Now, when I change the second parameter from 8 to 20 for instance, I get the 8 bytes I am expecting (from position 0 to 7) and some more other bytes (12 in total).
Why this is hapenning?
Attached Files
Igor Kondrasovas
www.inovativatec.com
#9
Posted 20 December 2011 - 05:21 PM
http://netmf.codeplex.com/
client_v4_2/CLR/Libraries/CorLib/corlib_native_System_Resources_ResourceManager.cpp
if(offset + length >= size) { length -= size - offset; }
Seems like this is wrong in at least a couple of ways. I think:
if((offset + length) > size) { length = (size - offset); }Is both clearer and less buggy.
So I think in your first case you ended up with:
if(0 + 8 >= 8) { length -= 8 - 0; }So your length ended up as 0 in this case.
if(0 + 20 >= 8) { length -= 8 - 0; }So your length ended up as 12 in this case (8 bytes of your resource data and four bytes of god knows what).
Happy to submit a patch, but I need to spend an hour and figure out how to do it and get the code. I was able to figure this out by browsing the source on CodePlex.
I'd say in the interim just make your resource one byte larger than you need. So nine bytes and then just know that the first eight are the "real" resource.
- Arron Chapman likes this
#10
Posted 05 January 2012 - 11:38 AM
Igor Kondrasovas
www.inovativatec.com
#11
Posted 22 November 2012 - 11:12 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users