Skip to content

File.Copy does two operations, for not win and then for win #91

Description

@Shlyonov
public static void Copy(string sourcePath, string destinationPath, bool overwrite)
		{
            if (Common.IsRunningOnMono() && Common.IsPlatformUnix()) SysFile.Copy(sourcePath, destinationPath, overwrite);

			string normalizedSourcePath = Path.NormalizeLongPath(sourcePath, "sourcePath");
			string normalizedDestinationPath = Path.NormalizeLongPath(destinationPath, "destinationPath");

			if (!NativeMethods.CopyFile(normalizedSourcePath, normalizedDestinationPath, !overwrite))
				throw Common.GetExceptionFromLastWin32Error();
		}

It should be "return" or smth after SysFile.Copy. For example:

public static void Copy(string sourcePath, string destinationPath, bool overwrite)
		{
            if (Common.IsNotWindows())
            {
                SysFile.Copy(sourcePath, destinationPath, overwrite);
				**return;**
            }

			string normalizedSourcePath = Path.NormalizeLongPath(sourcePath, "sourcePath");
			string normalizedDestinationPath = Path.NormalizeLongPath(destinationPath, "destinationPath");

			if (!NativeMethods.CopyFile(normalizedSourcePath, normalizedDestinationPath, !overwrite))
				throw Common.GetExceptionFromLastWin32Error();
		}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions