开发者

Which file writing methods are available under NTFS "Create Folders / Append Data" permissions?

For example, I am trying to use System.IO.File.AppendText's W开发者_StackOverflowriteLine, but that doesn't work, and I believe it's a permissions issue.


It seems that System.IO.File.AppendText opens the file for write access, and simply seeks to its end. Reviewing the code with Reflector should verify that, as will a quick breakpoint on kernel32!CreateFileW with WinDbg.

The program:

class Program
{
    static void Main(string[] args)
    {
        System.IO.File.AppendText(@"C:\Temp\blah").WriteLine("Boo");
    }
}

The breakpoint:

KERNEL32!CreateFileW:
757322fb 8bff            mov     edi,edi
0:000> dd esp
002cf1a8  58741b05 022ab244 40000000 00000001
002cf1b8  00000000 00000004 08100000 00000000
002cf1c8  14236e28 59e65d80 002cf270 0000001c
0:000> du 022ab244 
022ab244  "C:\Temp\blah"

The dwDesiredAccess parameter is 0x40000000, which is GENERIC_WRITE.

You will most likely have to construct a FileStream yourself:

new FileStream("blah", FileMode.Open, System.Security.AccessControl.FileSystemRights.AppendData, ...)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜