简体   繁体   English

C#:如何仅将文件中的差异从一个目录复制到另一个目录

[英]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. 我认为这不会比仅复制它们快。

What you're describing is exactly what rsync is best at. 您所描述的正是rsync擅长的 Use the tool best suited to the problem. 使用最适合该问题的工具。

Sure! 当然! There are plenty of diff implementations. 有很多差异实现。

Just adapt them to your needs. 只需使它们适应您的需求即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用C#中的cmd将文件从一个目录复制到另一个目录 - Copy file from one directory to another using cmd in C# 如何在C#中将文件从一个文件夹复制到另一个文件夹? - How to copy file from one folder to another in C#? 如何在C#中将文件从一个位置复制到另一个位置 - How to copy a file from one location to another in C# 如何使用c#窗口形式的progressBar将多个文件从一个目录复制到另一个目录 - how to copy multiple files from one directory to another with progressBar in c# window form 如何使用C#中的WinSCP .NET程序集将内容从一个远程目录复制到同一服务器中的另一个目录 - How to copy things from one remote directory to another in the same server using WinSCP .NET assembly in C# C#列表:如何将元素从一个列表复制到另一个列表,但仅复制某些属性 - C# Lists: How to copy elements from one list to another, but only certain properties 将访问控制属性从一个文件复制到另一个 C# - Copy access control properties from one file to another C# 将文件从一个目录复制到另一个目录 - Copy file from one directory to another 如何使用 C# 将选定列的所有行从一个 excel 文件复制到另一个文件 - How to copy all the rows of selected column from one excel file to another using C# 如何在C#中将一个列表复制到另一个列表 - How to copy one list to another in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM