Atomicity of File.Move

前端 未结 1 1019
一整个雨季
一整个雨季 2020-11-30 12:38

I want to rename a file in a directory as an atomic transaction. The file will not be changing directories. The path is provided as a UNC Path to an NTFS file system, probab

相关标签:
1条回答
  • 2020-11-30 13:03

    Yes, in NTFS. From here:

    As an aside if you are running under NTFS then file operations are atomic at the file system level. A rename will occur in a single operation as far as any higher code is concerned. The problem you are seeing almost appears to be an issue where the FileInfo object is being shared across applications. It is a MarshalByRef object and therefore can be used in remoting environments. Don't know if this applies to you.

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