Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Shlyonov opened this issue Dec 8, 2021 · 0 comments
Open

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

Shlyonov opened this issue Dec 8, 2021 · 0 comments
Assignees

Comments

@Shlyonov
Copy link

Shlyonov commented Dec 8, 2021

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();
		}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants