views:

244

answers:

1

Under most Unixes and Posix conforming operating systems performing an open() operating system call with the O_APPEND indicates to the OS that writes are to be atomic append and write operations. With this behavior,for local filesystems when you do a write, you know it get appended to the end of the file.

The Windows operating systems support the same funtionality by passing FILE_APPEND_DATA in the appropriate parameter to the Win32 CreateFile() system call.

references:

http://www.google.com/search?q=msdn+createfile
or: http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx

http://www.google.com/search?q=msdn+IoCreateFileSpecifyDeviceObjectHint
or: http://www.google.com/search?q=msdn+IoCreateFileSpecifyDeviceObjectHint

My problem is this, I cannot determine how to get this behavior under C# using the Net Framework Libraries, is there a way to get such behavior using the Net Framework? I do not believe using FileMode.Append gives such behavior, by the way.

Thanks

A: 

Why can't you use

System.IO.File.AppendAllText("C:\\somefile.txt", "some content");

? That's a thread-safe/"atomic" call as well.

enderminh
This unfortunatly doesn't give the process-wise atomic operation i'm looking for.
Scott