I need to walk a folder tree in C# and somehow record what I find, then pass it as a string to another device on my network, where I will display it graphically.
Walking the folder tree is simple with recursion, as is passing the string along.
However I would like the format of the string to be as portable as possible, so I thought of XML. I’m guessing I can somehow serialise the XML to a string.
I’m very new to XML, so I’m unsure how best to proceed. I’m thinking the format should end up something like this example:
<Tree>
<Folder Name="Folder1">
<File Name="File1" />
</Folder>
</Tree>
Any ideas? Do I use LinqToXML to build the string out of XElement objects like an example I’ve seen, or is that not the best way?
Ok so I went ahead with XElement – turns out it’s as easy as Chuck Savage said 🙂
usbKeyString ends up looking something like this: