[英]C#: How to copy only the differences in a file from one directory to another
Say I have a big file in one directory and an older version of it in another. 假设我在一个目录中有一个大文件,而在另一个目录中有一个旧版本。 Is it somehow possible to update the older version with only the changes in the new one? 是否可以仅通过新版本中的更改来更新旧版本? So that I would copy only a small fraction from one place to another. 这样我就只能将一小部分内容从一个地方复制到另一个地方。 Would have to work for both text and binary files. 必须同时适用于文本文件和二进制文件。
Not sure if this is possible though, but curious to if it is. 虽然不确定这是否可能,但对此是否很好奇。
I don't see any gained from such thing because to see the difference between two files you must read the whole files and compare them. 我看不出有什么好处,因为要查看两个文件之间的差异,您必须读取整个文件并进行比较。 I don't think this will be faster than just copying them. 我认为这不会比仅复制它们快。
May be a part of solution can be found with Sync Framework. Sync Framework可能是解决方案的一部分。 http://msdn.microsoft.com/en-us/sync/default.aspx http://msdn.microsoft.com/en-us/sync/default.aspx
A sample: http://www.c-sharpcorner.com/UploadFile/mail2sharad/FileSyncProvider01012008193150PM/FileSyncProvider.aspx 一个示例: http : //www.c-sharpcorner.com/UploadFile/mail2sharad/FileSyncProvider01012008193150PM/FileSyncProvider.aspx
Hope this help. 希望对您有所帮助。
Sure! 当然! There are plenty of diff implementations. 有很多差异实现。
Just adapt them to your needs. 只需使它们适应您的需求即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.