Daniele,
It probably would not be horribly efficient. Your best bet would be to
cycle through the file, byte by byte (or every two bytes, reading each
character). While doing this, you have to write the bytes to a temp file.
When you come across a byte or character that matches what you want to
replace (or the first character of such a string of bytes or characters),
you have to scan through, checking to see that the next n (where n is the
length of the string to be replaced) characters match. If they do, then you
write the replacement string to the new file.
Then, delete the original file, and move the new file to have the same
name as the old file.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Daniele said:
How is it possible to quickly substitute a string in a text file?
Thanks,
Daniele