What is the best way to create a properties file?

Hi, i want my Gadgeteer program to be able to read properties from a file.
Xml, is not supported, so as ini files…

What should i do?
I thought to save a file on the sd card and read it on start up.

Suggestions ?

XML is supported, but, as far as I remember, sits in a very weird library, that looks completely unrelated.

read XML was in one DLL, but the write XML was in another! I think one was in the DPWS libraries?

@ Gus - Yeah, might be. DPWS sounds weird enough :slight_smile:

Speaking of DPWS, I really liked one commit from GitHub NETMF repo:

“Removed DPWS support as it was broken in a prior release and no-one noticed, indicating a very low usage in the field.”

Yeah, no one noticed in, like, ten years? :slight_smile:

It’s under the DPSW extensions dll.

Also there is an example XML registry of mine in codeshare. :wink:


For a design I did I used a simple text file (INI) that I wrote out to the SD card. Something like this:


Each line is terminated by line feed and carriage return as you would expect. I then just read in each line at a time and parse them with the string strip on the = sign. I then have a simple switch and case that handles each one. Not the most elegant solution but it has been working in 2 designs out in the field without any failures. For something with only a few settings this works well.

Definitely agree with Dave. XML and JSON are data interchange formats, meant to be somewhat self-documenting for use between systems with different internal data marshalling. You don’t need a lot of the benefits there, so why pay the cost? Even Google, internally, uses a binary pipeline protocol that assumes both ends of the conversation understand the binary packages (both ends are generated from a text definition and then compiled).

So, use something like Dave specified and your code will be faster and more compact for about the same coding cost as working with an XML or JSON lib.

If you have effectively unlimited memory and CPU (as on a PC platform), then yes, use something like Newtonsoft JSON, but on an MCU and in situations where you are both the reader and writer, then use binary or minimal-decoration textual representations like Dave shows or an INI lib as mentioned earlier.

[Edit: If you have polymorphic data structures or complex hierarchies, then JSON is a better choice, but that is usually not the case for simple config tasks. For a number of space and time performance reasons, I would never advocate XML for config storage.]