In C#, is there a way to add an XML node to a file on disk WITHOUT loading it first?

前端 未结 8 1987
后悔当初
后悔当初 2020-12-20 14:14

I have a very basic XML structure/file on disk which is something like:


    kdkdkdk         


        
8条回答
  •  被撕碎了的回忆
    2020-12-20 15:01

    There are a a number of decent answers here already, however just to put another spin on this, are you sure this data needs to be stored as an XML file?

    The data you are storing looks fairly simple (i.e a record with three fields, date, type and some string data. If you do not need any of the added benefits that XML provides (see here) then why not just use basic CSV? That way you can just keep appending to it just like a log file via File.AppendText("filename").

    (Hell, it might even be possible to use something like log4net to manage the logging and any clean up housekeeping.)

提交回复
热议问题