BP Forums
Apply a diff file to another file - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+---- Thread: Apply a diff file to another file (/showthread.php?tid=510)



Apply a diff file to another file - Covert2String - 04-06-2012

Hello, so I need to apply a diff file to another file, the application should read the diff file and apply it, I just don't know how. Just like a regular file patcher, but instead of downloading the file, it just changes the original to the newer version.

Thanks in advance


Re: Apply a diff file to another file - brandonio21 - 04-06-2012

Can't you just use the
Code:
My.Computer.FileSystem.MoveFile(sourceFileName ,destinationFileName ,overwrite)

Method? And set overwrite to true so it overwrites the new file.


Re: Apply a diff file to another file - Covert2String - 04-07-2012

A simple patcher is easy... What I want to do is an application that gets which files are different, reads the diff file for each one and applies it to the client files. This would avoid downloading a 1 MB file just because I changed a variable for example.


Re: Apply a diff file to another file - brandonio21 - 04-07-2012

Ah, so you want to actually get into the binary code and change it to what the new version should be? If so, I don't really think this is possible due to the fact that executables are compiled, and the source code is not directly editable.


Re: Apply a diff file to another file - Covert2String - 04-07-2012

That's why I need to edit it like an Hexadecimal editor, I read the offset and the new value from a file in a webserver and edit the file in the client's PC.


Re: Apply a diff file to another file - brandonio21 - 04-07-2012

Well, to read the contents of a file, you need to use this code:

Code:
IO.File.ReadAllBytes("file path here")

So you could use that to find where the differences are. And then I'm guessing you can just use a StreamWriter to write them all back into the file.


Re: Apply a diff file to another file - Covert2String - 04-07-2012

I'll try it. Thank you, like always, you have the answer!


Re: Apply a diff file to another file - brandonio21 - 04-07-2012

Heh, Well I'm here to help! Please report back with your findings!


Re: Apply a diff file to another file - Covert2String - 04-09-2012

Well, fortunately the patcher won't need to change files this way, so I'll do it in the "normal" way, thanks though. Btw, I have a new question, please check the new topics