I have a need to merge two rtf files and have discovered its possible (a much simpler way than I've been seeing from others and codeproject) by appending the contents of file B to file A but before File A's closing }. I've done some testing to see if I could output File A to a test file minus the last } in the file, so I could than write in File B plus the closing } for file A, but the string replace function isnt working for me:
Please ignore any syntax errors besides the line I'm having trouble with (I converted it from VB)Code:RichTextBox rtbox1 = new RichTextBox; OpenFileDialog ofd = new OpenFileDialog; with ofd { .FileName = ""; .Filter = "Rich Text Format|*.rtf"; if (.ShowDialog == DialogResult.OK) { rtbox1.LoadFile(.FileName); System.IO.StreamWriter out = System.IO.File.CreateText("Temp.rtf"); out.WriteLine(rtbox1.Rtf.ToString.Replace(rtbox1.Rtf.ToString.LastIndexOf("}"), "@")); out.Close(); } }
The problem to be specific is with this line: out.WriteLine(rtbox1.Rtf.ToString.Replace(rtbox1.R tf.ToString.LastIndexOf("}"), "@"))
In the example I'm just testing it by replacing the last } with a @ but ideally I'd just want to remove it.



LinkBack URL
About LinkBacks



