❔ No atomic appends to file in .NET core?
I've used this snippet before to do atomic appends to a file https://stackoverflow.com/questions/1862309/how-can-i-do-an-atomic-write-append-in-c-or-how-do-i-get-files-opened-with-the but it seems that this no longer works in .NET core.
I found this attempt to fix https://github.com/dotnet/runtime/pull/55465 which was not merged and this proposal https://github.com/dotnet/runtime/issues/53432#issuecomment-902478772.
Is there any other way to accomplish atomic appends? I only really need macos support but it seems like cross plat isn't too much to ask (:
4 Replies
looking at the comments of the SO answer, it seems that overload was moved to here? https://learn.microsoft.com/en-us/dotnet/api/system.io.filesystemaclextensions.create?view=net-6.0#system-io-filesystemaclextensions-create(system-io-fileinfo-system-io-filemode-system-security-accesscontrol-filesystemrights-system-io-fileshare-system-int32-system-io-fileoptions-system-security-accesscontrol-filesecurity)
FileSystemAclExtensions.Create Method (System.IO)
Creates a new directory, ensuring it is created with the specified directory security. If the directory already exists, nothing is done.
Thanks let me give that a try!
those APIs only work on Windows for what it's worth
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.