开发者

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 M开发者_开发问答ono)


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.


Did you try File.Copy method? I have no experience with mono, but think that it should work. You will have to worry about file paths, which is different from API.


StreamWriter should work :),

Load data into memory via StreamReader?, and write it via StreamWriter or BinaryWriter. and there is even AsyncWrite if you want :)

I have an Custom Archive Format that runs on Mono, using these API's mentioned above. should be no different for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜