Programming2007
Programmer
Hello I am trying to write to a textfile at a certian position. The problem is that when I do that what I write to the file writes over the existing data. How do I do a write that is like an insert which just inserts the values into the textFile without replacing them. Below is my code:
FileStream fs = new FileStream(cabFile, FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs,Encoding.UTF8);
StreamReader streamReader = new StreamReader(fs);
str_rawFileData = streamReader.ReadToEnd();
RecordHeader = str_rawFileData.Substring(0, startIndex);
fs.Position = RecordHeader.Length;
sw.Write("|");
FileStream fs = new FileStream(cabFile, FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs,Encoding.UTF8);
StreamReader streamReader = new StreamReader(fs);
str_rawFileData = streamReader.ReadToEnd();
RecordHeader = str_rawFileData.Substring(0, startIndex);
fs.Position = RecordHeader.Length;
sw.Write("|");