开发者

Setting CreationTime of a directory

开发者 https://www.devze.com 2023-03-23 02:58 出处:网络
I am trying to set the creation time of a directory with C#. This works very easy with files in this way:

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);
0

精彩评论

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