Search code examples
c#.netmonocross-platformpinvoke

C#/CopyFile: Cross-platform code with Progress


Please suggest me a C# cross-platform solution to copy a File with progress. The method should be able to copy the file on Mono as well on .NET.

P.S. Most of the solutions here refers to CopyFileEx (which uses PInvoked and I am not sure if this will works on a Mono)


Solution

  • You can manually copy between filestreams, like the CopyFile method in MonoDevelop's file deployer, which has a callback after every 1k chunk.

    It's probably a fair bit slower than File.Copy, but if progress callbacks are essential you don't have much choice. In the case of the MonoDevelop file copier, we write to locally-mounted remote file systems via FUSE.