0

There is an 'Accessed' meta data which is shown as part of the properties window of a file.is there a programmatically way to delete this info or set it to something else? Thank you enter image description here

Avishay
  • 305
  • 1
  • 11

2 Answers2

1

The FileInfo class can take care of this for you.

[TestMethod]
public void SetLastAccessTime()
{
    String fileName = @"D:\Sample.txt";

    FileInfo fi = new FileInfo(fileName);
    fi.CreationTime = DateTime.Now.AddDays(10);
    fi.LastWriteTime = DateTime.Now.AddDays(10);
    fi.LastAccessTime = DateTime.Now.AddYears(-2);
}

And, this is what the file properties looks like after this code has run.

File properties after this code runs

JayV
  • 3,238
  • 2
  • 9
  • 14
1

After a small search I found this in File.SetLastAccessTime Method

Haven't used it myself but according to MSDN you can set the Access time with this:

File.SetLastAccessTime
S.Fragkos
  • 301
  • 2
  • 9