Reputation: 77329
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!
Upvotes: 5
Views: 5614
Reputation: 29745
Here's something I just Googled, might be helpful as a starting point:
An O(ND) Difference Algorithm for C#
Upvotes: 1
Reputation: 7563
here are some articles to some diff algorithms explained in C#
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.
Upvotes: 2
Reputation: 50273
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.
Upvotes: 0
Reputation: 2638
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
Upvotes: -1