public static void CopyFile(FileInfo source, FileInfo destination, Statements.FileCopyOptions options, CopyFileHandler callback, object state) { if (source == null) { throw new ArgumentNullException("source"); } if (destination == null) { throw new ArgumentNullException("destination"); } new FileIOPermission(FileIOPermissionAccess.Read, source.FullName).Demand(); new FileIOPermission(FileIOPermissionAccess.Write, destination.FullName).Demand(); CopyProgressRoutine cpr = (callback == null) ? null : new CopyProgressRoutine( new CopyProgressData(source, destination, callback, state).CallbackHandler); bool cancel = false; if (!NativeMethod.CopyFileEx(source.FullName, destination.FullName, cpr, IntPtr.Zero, ref cancel, (int)options)) { throw new IOException(new Win32Exception().Message); } }