简体   繁体   English

更新文件,而不是替换或覆盖

[英]Update file, not replace or overwrite

this is more of a question because I am experimenting with this. 这更像是一个问题,因为我正在尝试这个。

All over the internet I see how you can update a .txt file. 在互联网上,我看到你如何更新.txt文件。 Well that is all good and well, but lets say I have a .doxc or even an .exe or even a .dll file. 嗯,这一切都很好,但是我可以说我有.doxc甚至是.exe甚至是.dll文件。

If we make a minor change to a file, do we really have to replace(overwrite) the whole file? 如果我们对文件进行微小的更改,我们真的必须替换(覆盖)整个文件吗?

Is it possible to "update" the file so that we don't use too mush data (over the internet). 是否可以“更新”文件,以便我们不会使用过多的数据(通过互联网)。

What I am trying to achieve is to create a FTP client with a FileSystemWatcher. 我想要实现的是使用FileSystemWatcher创建一个FTP客户端。 This will monitor a certain folder on the Computer. 这将监视计算机上的某个文件夹。 If anything changes in this folder (even sub directories) then it uploads, deletes, renames, or changes the file. 如果此文件夹(甚至子目录)发生任何更改,则会上载,删除,重命名或更改文件。 But at the moment I am wondering if I have, lets say, a 20MB .exe file or whatever, if it is possible to change something in that .exe, instead of just overwriting the whole thing... thus, sparing some cap. 但是目前我想知道我是否有一个20MB的.exe文件或者其他什么,如果有可能改变那个.exe中的东西,而不是只覆盖整个东西......因此,节省了一些上限。

Since your are experimenting, I can provide some pointers. 既然你正在试验,我可以提供一些指示。 But I dont know for sure if the below operations are just updates or replaced newly by the underlysing os calls 但我不确定以下操作是否仅仅是更新或者由于欠调的操作系统新替换

  • Have different cases for each file type. 每种文件类型都有不同的情况。 Try with a basic types first, a txt file, then a binary file etc. 首先尝试基本类型,txt文件,然后是二进制文件等。
  • You should have the entire copy of the current file somewhere, sine you "should" compare the old file to know what changes 你应该把当前文件的整个副本放在某个地方,正弦你“应该”比较旧文件,知道有什么变化
  • Then when a change is made to the file compare it with the old file eg) in a text file with 1 MB and the change is only 1 KB you will need to build a format like 然后,如果对文件进行了更改,将其与旧文件进行比较,例如,在1 MB的文本文件中,并且更改只有1 KB,则需要构建类似的格式
    • [Text][Offset][[operation]
    • eg) [Mrs.Y][40][Delete] then [Mr.X][40][Add] 例如) [Mrs.Y][40][Delete]然后[Mr.X][40][Add]
  • Then your ftp client should be able to implement this format and make changes to the local copy on the client. 然后您的ftp客户端应该能够实现此格式并更改客户端上的本地副本。

In general, it's possible to update the remote file only partially, but not in your case. 通常,可以仅部分更新远程文件,但不是在您的情况下。

What would work: 1) track the file change using a filesystem filter driver, which gives you information about what parts of the file have been updated. 什么工作:1)使用文件系统过滤器驱动程序跟踪文件更改,该驱动程序为您提供有关文件的哪些部分已更新的信息。 2) use the protocol which allows partial upload or remote modification of the file (eg. SFTP). 2)使用允许部分上传或远程修改文件的协议(例如SFTP)。

As for your scenario: 至于你的场景:

Step 1 is not possible with FileSystemWatcher. FileSystemWatcher无法实现步骤1。 Step 2 is not possible with FTP protocol which doesn't support modification of file blocks. FTP协议不支持步骤2,不支持修改文件块。

不可以只将更改上传到.exe文件。我们必须覆盖它。

@Frederik - It would be possible if FTP supports an updating of resource like HTTP's PUT command. @Frederik - 如果FTP支持像HTTP的PUT命令那样的资源更新,那将是可能的。 Try exploring that angle. 尝试探索这个角度。 Let us know if you find something. 如果您找到了什么,请告诉我们。

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

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