Setting CreationTime of a directory
I am trying to set the creation time of a directory with C#.
This works very easy with files in this way:
FileInfo fi = new FileInfo(strFile);
fi.CreationTime = DateTime.Now;
So I tried it with a path to a directory and got an object (so FileInfo
worked on a directory) and it threw an UnauthorizedAccessException
when setting the time like in the code above.
I am working on Windows 开发者_StackOverflow中文版7 64bit and have administrator-rights on.
Question: So, how can I set the creation time of a directory?
I got it with this, haven't seen it yet....
Directory.SetCreationTime(strFile, DateTime.Now);
精彩评论