简体   繁体   中英

C# Get the difference between two files and use it for incremental backup

I want to create my own incremental backup solution using C#. How can I obtain the difference between two files (version 1 and version 2 of ABC.TXT) and then update ABC.TXT version 1 with the difference? Would appreciate some hints! Thank you!

here are some articles to some diff algorithms explained in C#

Codeproject 1

Codeproject 2

Its not easy to get this algorithm right. I would suggest executing kdiff3 or some other good diffing tool in a background process rather than writing it yourself.

Here's something I just Googled, might be helpful as a starting point:

An O(ND) Difference Algorithm for C#

Do you really need incremental backup? Is there any reason why you can't just replace version 1 with version 2?

And as Jon pointed, probably you'd better use an already existing and tested backup solution.

I'm not sure as to how exactly you would replace the 'difference' text as that could get quite complex. But for the initial checking, you could compare the file sizes.

The link below might help you out:

http://dotnetperls.com/file-size

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM