Aykut Çevik
Aykut Çevik

Reputation: 2088

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 7 64bit and have administrator-rights on.

Question: So, how can I set the creation time of a directory?

Upvotes: 1

Views: 1222

Answers (1)

Aykut Çevik
Aykut Çevik

Reputation: 2088

I got it with this, haven't seen it yet....

Directory.SetCreationTime(strFile, DateTime.Now);

Upvotes: 3

Related Questions