Is XMLDocument.Save an atomic operation?

后端 未结 4 919
傲寒
傲寒 2021-01-12 08:58

Is there anyway another process monitoring for files created using XMLDocument.Save() could encounter a partial file? Does it make any difference if Save() is overwriting an

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-12 09:18

    Writing files is, in general, not atomic. Check out Process Monitor to get an idea what the OS exposes.

    XmlDocument.Save(string) uses FileShare.Read. ChaosPandion's solution specifies FileShare.None. Check out System.IO.FileShare on MSDN for the difference.

提交回复
热议问题