Hello,
occasionally, after several successful calls to System.IO.File.Copy, the method fails with the following exception:
System.IO.IOException: Invalid access to memory location.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost)
at System.IO.File.Copy(String sourceFileName, String destFileName)
So the LastWin32Error is 998 (0x000003E6) = ERROR_NOACCESS = Invalid access to memory location.
I cannot find any information on this error occuring in the CopyFile function of kernel32.dll. The funny thing is, from another dummy .NET app started in parallel, the exact same copying works. Also System.IO.File.WriteAllBytes(dest, System.IO.File.ReadAllBytes(source));
works even when System.IO.File.Copy(source, dest);
throws this exception.
ProcessMonitor just shows the source file being succesfully opened for reading and then being closed again, and no operation on the destination file.
I'm using .NET Framework 4.8