• 0

[C#] Writing parts of large files


Question

How can u just write parts of files?

eg a file contains

option1 = x

option2 = yyz

option3 = sdefd

option4 = er

option5 = qscd

say i wanted to change option 4 to "ppl" how could this be done withoguth having to rewrite the rest of the file 2?

the actual aplication for this will deal with much larger binary files but the consept in the example is the same.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

You will need to seek to the position of the option and then just write the data (which will overwrite the existing data), however this can become more difficult if you are dealing with items of varible size (e.g. in the example above you want to change something that is 2 charactors to something that is 3 charactors).

Sorry no code examples as I have never had to deal with binary files with my .Net applications yet.

Link to comment
Share on other sites

  • 0

With streams you can seek to a specific position. If you know the content of the file will always be identical, then seeking to the position where you want to start writing is easy. With variable length positions, you may need to use markers or something like that.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.