Saving Data

Hi all,
How can I store some data on flash? And how can I read?

Use EWR (Extended weak references).

There is an example that comes with .NET MF.

On my machine it is located at C:\Users\mike\Documents\Microsoft .NET Micro Framework 4.2\Samples\ExtendedWeakReferences

This assumes that you want to be able to write it from your program and then read it back.

Otherwise, consider using resources. for read only.

Thanks a lot. I’m checking.

Note that EWR is not available on Cerb family

Sorry for late reply.
I tried EWR sample. It works for reboot, but not for power down. Do I miss something? I want to save some data permanently.
Thanks a lot.

there is a parameter that determines whether the object survives power down.

check out this discussion

Thanks a lot Mike. Sample works fine.
But when I combine it with my application, I have trouble. I think my problem is shutting device down. My code doesn’t reach the end of Main because I unplug.
Application.Current.Shutdown() gives an error. Any suggestions?

No sure what you mean? With Gadgeteer, main should never exit. Gadgeteer is event driven.

Also, an embedded application should never “shutdown”. What are you trying to achieve?

There is a delay before your EWR object is actually written to flash. I have not used it, but I believe there was a flush function added to the EWR functionality in MF 4.2 to write any pending EWR objects to flash.

I copied the code from sample to my application. It works if I reboot from Debug, but it fails if I unplug or reset. As I see, only difference between Sample and mine app is Sample finishes Main, but mine doesn’t. Thats why I asked. I will keep trying. Thanks.

hi a quick search in code share gave many examples:
here is one:

please do a search and study those examples.

Good luck.

and here is a post that talks about the flush function that mikes mentioned:

Thanks a lot.

Of course I did. I think I didn’t choose correct keywords :S
Thanks again.

Yah i know; the search on CodeShare is a bit funky and has it’s own mind…so you might want to start using bing to search Codeshare:

type this in the bing search:


and here is what i got when using the search: