Atomic file copy under .NET

后端 未结 4 2006
南笙
南笙 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:00

    Newer versions of Windows allow you to use transactions .

    0 讨论(0)
  • 2020-12-06 18:03

    Transactional file system.

    0 讨论(0)
  • 2020-12-06 18:03

    Check out Background Intelligent Transfer Service in Windows Server 2003. It provides the mechanism of jobs, which can be paused and resumed even after restart.

    Here are a few samples how to use it with .NET:

    Write Auto-Updating Apps with .NET and the Background Intelligent Transfer Service API

    SharpBITS.NET - wrapper for BITS API

    0 讨论(0)
  • 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

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