Deserializing large xml files (>500kb) can be quite slow, because it produces a lot of harddrive IO operations. There is a simple trick to avoid this using a memory stream:
UTF8Encoding encoding = new UTF8Encoding(); XmlSerializer serializer = new XmlSerializer(typeof(MyClass)); MemoryStream stream = new MemoryStream(encoding.GetBytes(File.ReadAllText(filename))); MyClass myClass = (MyClass)serializer.Deserialize(stream);
Trackbacks/Pingbacks