Helge Jensen wrote:
On unix-based systems i use (the libc function) "rename" to do atomic
replacement of one file with another.
How would I achieve the same using .NET primitives?
There are two Windows API functions that might be useful: ReplaceFile and
MoveFileEx. Both seem to be able to replace a file if used with the
correct parameters, but none of them guarantee atomicity. I don't think
any of them is available via .NET framework classes.
I googled for "windows posix rename" and I came up with a few mailing list
threads discussing the issue, with the general consent being that Windows
can't do it - many things in Windows file handling aren't very POSIX
compatible, after all.
Oliver Sturm
--
Expert programming and consulting services available
See
http://www.sturmnet.org (try /blog as well)