Closed
Description
string path = Path.GetTempFileName();
File.SetLastWriteTime(path, new DateTime(2000, 1, 1)); // succeeds
File.SetAttributes(path, FileAttributes.ReadOnly);
File.SetLastWriteTime(path, new DateTime(2001, 1, 2)); // throws UnauthorizedAccessException
This is because SetLastWrite time tries to open a file handle with GENERIC_WRITE instead of only FILE_WRITE_ATTRIBUTES. This bug exists in .NET Framework as well and has been encountered by customers eg here and now reported in a DTS issue.