Re: WriteFile, insert data in the middle of the file.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Well you answered your own question. There is no way to write to the middle
of the file without overwriting what's already there. In other word, you
can't expand a file in the middle.
What most programs do is create a temp file write everything they want to
that, then simply delete the old file and rename the temp file to the
correct filename.

AliR.

"wk" <wk@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:95B74BD6-9C73-4150-BFF3-7694D337CA8D@xxxxxxxxxxxxxxxx
> Hello,
>
> What I want to do is to insert data (not overwrite existing data) in the
> middle of a big file. Does WriteFile( ) have this option?
>
> If there's no way to insert data in the middle, I guess I have to read out
> all the data from the insertion point, and append my new data, and write
them
> back to the file? Isn't this too inefficient? Anybody knows how OS handles
> this kind of "insert in the middle" scenario?
>
> Thank you, I appreciate your opinion.
>
> wk
>


.



Relevant Pages

  • Re: duplicate input
    ... but the answer may be that dealing with a temp file involves all ... the trouble generally associated with a temp file (not ... overwriting, where to put it, permission problems, what to do if ...
    (comp.unix.shell)
  • Re: Capture console output to file ?
    ... In article, Jeffrey Ross wrote: ... > If you want to append to these files rather than overwriting them use ... > If you want both stdout and stderr in the same file (noting that they may ...
    (linux.redhat)
  • Re: Append to the end of file when "write"
    ... append the new content to the end of the file (instead of ... overwriting the current content). ... FileStream lStream = ... The FileInfo class exposes an AppendText method, ...
    (microsoft.public.dotnet.general)
  • Re: path keeps bloating with repeated entries on invoking subshells
    ... I thought this was the right way to go since I only append to the ... systemwide path settings without overwriting anything as a user. ... duplicate entries (I guess a side-effect of appending the $path at the ...
    (comp.os.linux.misc)
  • Re: Append mode in write operation
    ... overwriting the current content). ... believe the append mode is defined with different parameters from the ... What are the correct parameters to define the "append" ...
    (microsoft.public.dotnet.general)