Atomic file copy under .NET

后端 未结 4 2018
南笙
南笙 2020-12-06 17:45

I am building a server app that copies files using System.IO.File.Copy(...) function. My files can be rather large, therefore, it has a fair chance that if the machine crash

4条回答
  •  伪装坚强ぢ
    2020-12-06 18:08

    Other have suggested transactional NTFS which is fine if you're deploying on Vista or later. If you need to support XP (or earlier) then temporary file followed by a move (rename) is the best solution.

    The answer to this similar question provides more info: Atomicity of File.Move

提交回复
热议问题