I am trying to write a simple Cacheing function. I am checking to see if a file saved on the hard drive is order than some prescribed limit. If it is less than the limit, I used the cached file, if older I download and save a new file. I have run into problems checking the age of the file. here is some test code
The result is the filesavetime is exactly the same as filesavetime2. I know the file.delete should not be needed. The file.createText should overwrite the file. I just tried to use it to clear out the file.
Any idea on how to accurately get the file creation time?
Code:
Dim filesavetime As Date
Dim filesavetime2 As Date
Dim sw As StreamWriter
filesavetime = File.GetCreationTime("myfile.txt") ' this file was created minutes earlier
File.Delete("myfile.txt") ' this should not be needed.
sw = File.CreateText("myfile.txt")
sw.WriteLine("dog")
sw.Close()
filesavetime2 = File.GetCreationTime("myfile.txt")
Any idea on how to accurately get the file creation time?