views:

61

answers:

1

I'm trying to write a simple program that will backup my flash drive. I want it to work automatically and silently in the background, and I also want it to be as quick as possible. The thing is, resetting all the access times is useless to me, and something I want to avoid. I know I can read the access times and set them back, but I bet it will fail one day in the future. It would be much simpler to read the files without ever changing it. Also, what is the fastest way to do this? What differences would there be between, say, a flash drive and an external hard drive.

I am writing this in C#, as it is the simplest way to do it and it will probably last more generations of Windows..

+3  A: 

That's not a logical assumption. The FileInfo.LastAccessTime property is frozen in the .NET specification, it is sure to outlast your C# code. If there will ever be a version of Windows that for some mysterious reason doesn't support a last-accessed time stamp on a file then it will be Microsoft's burden to re-implement the property in a reasonable way. The semantics of the property are frozen too, and have been for the past 17 years, there will never be a version of Windows that lets you read from a file but not update the value.

Btw, you should also reset the FileAttributes.Archive bit.

Hans Passant
FileAttributes.Archive? what does that do? Also, I want to use C# because I won't have to recompile it for Windows 8.
The Archive bit indicates that the file wasn't yet backed up. It is automatically set by Windows when the file is modified. A back-up program must reset it. All of this can be done from C#, use the FileInfo.Attributes property.
Hans Passant
@johnathan You don't have to recompile for each version of Windows with native applications. Application written for XP should work fine in 7.
svick