Thread: String Replace Function

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    49

    String Replace Function

    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:

    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();
                    }
                }
    Please ignore any syntax errors besides the line I'm having trouble with (I converted it from VB)

    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.
    Last edited by kairozamorro; 08-20-2009 at 02:32 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. Using the string replace function
    By FoodDude in forum C++ Programming
    Replies: 7
    Last Post: 09-23-2005, 02:31 PM
  4. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  5. Linked List Help
    By CJ7Mudrover in forum C Programming
    Replies: 9
    Last Post: 03-10-2004, 10:33 PM