Safest place for the XmlSerializer to save temp files

前端 未结 1 632
长发绾君心
长发绾君心 2021-01-06 07:19

It\'s come to my attention that the XmlSerializer needs to use disk space to do its bidding. If there is no writeable %temp% folder, then it fails with an error as follows:<

相关标签:
1条回答
  • 2021-01-06 07:47

    DataContractSerializer, NetDataContractSerializer and DataContractJsonSerializer would all be good alternatives for you. They do NOT require disk space and do NOT emit assemblies to disk. Instead, they generate IL on the fly (in memory) and use it during subsequent serialization episodes to do serialization and deserialization all within the AppDomain they're operating in. XmlSerializer does require disk space, as you found out. On the plus side, you shouldn't need to change any of your types -- just replace the serializer and you should be good to go, since DataContractSerializer supports the serialization formats, models and paradigms of all the other serializers that Microsoft has ever shipped in .NET

    0 讨论(0)
提交回复
热议问题