C# Convert Byte Array to Generic List
c#, resources
Solution
In what way have you serialized it? Normally you would just reverse that process. For example:
BinaryFormatter bf = new BinaryFormatter();
using(Stream ms = new MemoryStream(bytes)) {
List<Foo> myList = (List<Foo>)bf.Deserialize(ms);
}
Obviously you may need to tweak this if you have used a different serializer! Or if you can get the data as a `Stream` (rather than a `byte[]`) you can lose the `MemoryStream` step...
Problem
I have a custom list which I want to embed as a resource so it can be copied out with each new install. However, my list is serialized as a binary file and when I add it as a resource I can't just copy it out because C# treats it as a byte array. I need to be able to convert this byte array back to my custom list when I extract the file from my resources. Can someone give me an idea of how to accomplish this conversion? Thanks!