spike232 Posted September 21, 2004 Share Posted September 21, 2004 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 More sharing options...
0 +virtorio MVC Posted September 22, 2004 MVC Share Posted September 22, 2004 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 More sharing options...
0 Sn1p3t Posted September 22, 2004 Share Posted September 22, 2004 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 More sharing options...
0 Steven Posted September 22, 2004 Share Posted September 22, 2004 IO.StreamReader.FileIO.Seek("Something") I haven't played with files in a while :s Link to comment Share on other sites More sharing options...
Question
spike232
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