FileSystem.CopyFile IOException timing and data integrity
0 reputation · 08 Aug 2026, 09:08 UTC
File Restoration Behavior
When implementing a backup restoration routine using Microsoft.VisualBasic.FileIO.FileSystem.CopyFile, the Overwrite parameter determines whether an existing destination file is replaced. If set to False and a file already exists at the target path, the method triggers an IOException.
Verification Constraints
The current documentation does not specify the exact sequence of operations regarding this exception. It is unclear if the IOException is raised during a pre-check phase before any I/O occurs, or if it occurs after a failed attempt to open the destination file for writing.
Furthermore, the method provides no native mechanism to verify that the recovered data matches the source, such as a checksum or byte-count validation, leaving the integrity of the restoration to the developer's implementation.
- Does the
IOExceptionoccur before or after the system attempts to access the destination file? - Is there a documented way to ensure file integrity within the
FileSystemclass, or must external hashing be used?