Instance Hunter
Instance Hunter

Reputation: 7925

Is FileInfo.CopyTo / File.Copy guaranteed to succeed?

By "guaranteed to succeed" I mean: If no Exception is thrown on the call to CopyTo, can I safely assume that the file was copied perfectly, or would it be reasonable to validate the copy (such as with a checksum)? This of course assumes that the integrity of the file is mission-critical.

Upvotes: 0

Views: 808

Answers (1)

to StackOverflow
to StackOverflow

Reputation: 124776

The file will be closed. You can be sure that anyone else attempting to read the file will get a complete file. But you can't be sure that all data buffers have been flushed to disk, so in the event of e.g. a system crash data could be lost.

Upvotes: 1

Related Questions