I'm a bit of a newbie to C# and I've never done anything with XML. Most of my experience is C code written for microcontrollers, with some C/C++ and linux scripting experience, but never any XML.
Basically, I've got a bunch of firmware update files in a folder, currently about 50, but users could have as many as a hundred or more, especially if they don't delete old versions or the program gets expanded to support additional hardware. My program needs to check all those files, parse a little data out of them, and store it in some fashion for quick lookup. I thought about just doing a CSV file, but figured I might as well learn a little about XML in the process.
My first problem is formatting the data. One firmware file may cover multiple hardware models, and there can be multiple versions of the firmware for one model. When the program starts, it will need to make a list of all the file names currently in the XML file and compare them to those in the folder. Later it will need to find all the files with the right model name. I've come up with a couple different formats for storing the data, I'm currently leaning towards option 2, but I'd really appreciate an expert opinion.
Option 1:
<Model model="Model String">
<FirmwareFile filename=foo.bar>
<Version> "1.2.3" </Version>
<DateCode> "05082015" </DateCode>
</FirmwareFile>
<FirmwareFile filename=foo2.bar>
[...]
</FirmwareFile>
</Model>
Option 2:
<FirmwareFile filename=foo.bar>
<Models>"Model A", "Model B"</Models> //probably not the right way to do this
<Version> "1.2.3" </Version>
<DateCode> "05082015" </DateCode>
</FirmwareFile>
The other problem is which library and which method of retrieving the data would be best. The way I see it, I have two options for working with the file, either I read through it on the disk twice (the first time reading file names, the second time to look up model numbers) and write/delete entries from it directly, or else I read all the data once into memory (probably a list of a class), and if anything changes rewrite the file. Which way should I be going? And which library should I be using?
Thanks!
Aucun commentaire:
Enregistrer un commentaire