How to maintain format of ".rtf" file after save?

Hello and thank you for taking your time. I have been facing some problems with my project for a while regarding the
LoadFile  method . I have a project in Which I can can select several things and show them in a different
RichTextBox. Now, through the press of a button I can Save the contents of that of That
RichTextBox (The contents are formatted as in they have Bolded Text) in a
Rich Text File (.rtf) . I implemented the method of saving through creating a function called "WriteInFile" which writes the Boxes` contents in a ".rtf" file.  This is The code :
public void writeInFile(String name)
name = "Your Program";
name = String.Concat(name, ".rtf");
file = name;
TextWriter tw = new StreamWriter(@name);
tw.WriteLine(textBox1.Text);
foreach (var line in richTextBox1.Lines)
tw.WriteLine(line);
tw.Close();
Then I load "Your Program.rtf " through  the press of a different button, in the
same RichTextBox using the following code :
private void button4_Click_1(object sender, EventArgs e)
richTextBox1.LoadFile("Your Program.rtf", RichTextBoxStreamType.PlainText);
My problem is that when I load the file I want it tokeep its format,with bold etc. If I use the same code but insert ".RichText" It says that the format is invalid
(throws an exception) using ".PlainText" is fine ,also using a ".txt" format is fine it is just that
the format is not kept . I really do not know how to solve this...
Thank you for your time!

Try a different way:
// save:
richTextBox1.SaveFile(name, RichTextBoxStreamType.RichText);
// load:
richTextBox1.LoadFile(name, RichTextBoxStreamType.RichText);

Similar Messages

  • How do I look at pdf files after installing adobe reader?

    how do I look at pdf files after installing adobe reader?

    Start Adobe Reader
    Use the menu File > Open...
    Select the PDF file

  • How do I recover a word file after a force quit

    how do i recover a word file after a force quit

    Do you have Word's AutoRecover switched on?

  • How to reduce the size of file after delete some datas?

    The size of the database file isn't smaller than ago after delete some data from database.
    How to reduce the size of file after delete some datas?

    Hi,
    What BDB release are you using? If it's one of the latest releases, then what you are looking for is the DB->compact() method:
    http://download.oracle.com/docs/cd/E17076_01/html/api_reference/C/dbcompact.html
    The DB->compact() method compacts Btree, Hash, and Recno access method databases, and optionally returns unused Btree, Hash or Recno database pages to the underlying filesystem. Please let me know if it helps.
    Bogdan Coman

  • How to display data from *.rtf file with apex in user-frienldy format?

    Hello!
    Well, in my database I have column "Problem" which type is CLOB, and there is text from some *.rtf file, e.g.
    "{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset238{\*\fname Arial;}Arial CE;}{\f1\fmodern\fcharset238{\*\fname Courier New;}Courier New CE;}{\f2\fnil Arial;}} {\colortbl ;\red0\green0\blue0;\red0\green0\blue68;} \viewkind4\uc1\pard\cf1\lang1045\f0\fs20 Dla podanego poni\'bfej dokumentu XML zdefiniuj schematy XML (pliki XML-Schema), kt\'f3re pozwoli\'b3yby na jego walidacj\'ea. Przy definicji ka\'bfdego ze schemat\'f3w okre\'9cl jego nazw\'ea. \par \par \pard\cf2\b\f1 <?xml version="1.0" encoding="UTF-8"?> \par <s3:A1 xmlns:s1="udasie" xmlns:s2="czy" xmlns:s3="nie" \par xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" \par xsi:schemaLocation="nie schemat3.xsd czy schemat2.xsd" \par C3="u"> \par \lang1033 <C3>d</C3> \par <B2>a</B2> \par <s1:A1 s1:A1="s"> \par \lang1045 <s1:B2>i</s1:B2> \par <s1:C3>e</s1:C3> \par <s2:B2> \par <A1>na pewno</A1> \par </s2:B2> \par </s1:A1> \par </s3:A1>\fs28 \par \pard\cf1\b0\f2\fs20 \par } ?
    And the problem is:
    in my APEX appliactions I only want to display this *.rtf text in user-friendly format (http://cerber.cs.put.poznan.pl/~inf71287/screen.png).
    Is there any simple way to do this?
    This is how it looks now: http://cerber.cs.put.poznan.pl/~inf71287/not_good.png - unreadable ;-)
    Thanks for any suggestions :)
    Buczuss
    Message was edited by:
    Buczuss

    A new preference has been added to customize the import delimiter in main code line. This should be available as part of future release.

  • How do I fix placed RTF files?

    I am using CS4 to place several word documents into a book and I am having the usual issues of crashing when trying to place doc files. I am not using any special tables, graphics or fonts, and even if I disable all the import options it usually crashes.
    I can sometimes get a regular doc to work but it randomly garbles the text and removes footnotes, so I don't trust this.
    RTF seems to work so I think I am going to go with that, but it creates anomalies. I don't mind deleting the random spaces it creates (though this is tedious) but one thing it does which I don't know how to undo is that in the odd footnote here and there it creates a thin black box around some or all of the text. How do I get rid of this box? I can sometimes just retype whatever is in the box beside it and then delete the boxed text altogether but I can't do this when the box encompasses the entire footnote.
    Any suggestions?

    I'm still having trouble placing one document. It is a simple text document with footnotes but no tables, graphics, or lists. It has no hyperlinking in it. I have tried using .doc, .docx, and .rtf files, including those made on Word 2010, 2007, and 2003. Each time the result is the same: about 1/3 of the document is placed and it abruptly gets cut off in the middle of a sentence. The red box appears after 2 or 3 blank pages but will not actually add any more text if I try and do so. According to the story editor there is overset text in both the body and footnotes, but I don't know why this would be since I am there is just plain text and I have footnote splitting on.
    I am at a total loss for this. Some have mentioned using programs to clear formatting, but it is very important that I not lose the numerous italics in the document. That would be a deal breaker.
    Any advice? I don't have access to any other versions of ID besides my CS4 here. The other documents have been placed by one method or another - different rtf files. But this one just won't work.

  • How to maintain format in html email using the send email....

    Does anyone know how to maintain the format in a HTML email using the Send E-mail To Recipients From Recordset behavior?
    When text only is selected instead of HTML text on the Options tab the format of the input is maintained, but when HTML text is selected the email has no format. I have tried to use a replace \n with
    as I have done when hand coding PHP, BUT I am trying to learn to use ADDT. I also tried to use a Custom trigger without success.
    Help!

    Hi Dave,
    in my snippets folder I have this thing which I found on the old MX Kollection forums and which was suggested by the Interakt staff:
    //trigger SendEmail (write content)
    function Trigger_SendEmail(&$tNG) {
    ob_start();
    include("myDynamicContentFile.php");
    $mailcontent = ob_get_contents();
    ob_end_clean();
    $emailObj = new tNG_Email($tNG);
    $emailObj->setTo("[email protected]");
    $emailObj->setFrom("[email protected]");
    $emailObj->setSubject("A new User was added");
    $emailObj->setContent($mailcontent);
    $emailObj->setEncoding("UTF-8");
    $emailObj->setFormat("text");
    $emailObj->setImportance("Low");
    return $emailObj->Execute();
    //trigger SendEmail (write content)
    The only modification is the possibility to include a dynamic PHP file rather than some static text or a HTML file which will also render textarea contents on one line:
    ob_start();
    include("myDynamicContentFile.php");
    $mailcontent = ob_get_contents();
    ob_end_clean();
    That said, it should be possible to define all the "rendering" options in the external PHP file, what would mean to apply the nl2br function there, e.g.: nl2br($row_queryname['columnname'])
    What I´m not sue about is, if you will have to strip the external file´s head and body tags before it´s getting included -- however, please give this a try and tell us how it worked.
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Got problems with creating RTF-files after OSX update

    Hi
    I don't know if this is really a MAC OS problem, but it occurred after I updated to 10.5.2 - so it's a likely suspect.
    Since the update I can't create RTF-files any more with Final Draft, my script writing program. A file is created, but when I try to open it I get an error message that it cannot be found. But the file is there: I can see it and click on it. It just won't open.
    Only today now I got the same error message with a doc-file I downloaded some months ago.
    The only big change I lately made to my Mac was the update to 10.5.2 and I got the new Office 2008 (both are the German versions). Could the problem come from either of them? I contacted Final Draft's support - they didn't know of the problem.
    Maybe someone else in this forum has encountered similar problems?

    Have you tried to Repair Permissions using Disk Utility?
    1. Open Disk Utility in your Applications/Utility folder.
    2. Click on the icon for your boot volume.
    3. Click on the First Aid tab and select Repair Permissions
    4. Click the repair permissions button.
    This is the first thing to try whenever any program goes wonky. It's free, but takes awhile for all the files that have to be checked and changed.

  • Recovering a .rtf file after non-complete saving on Dropbox

    Hi,
    I was working on a .rtf file named meeting.rtf (inventive I know!) yesterday that I thought I had saved to my desktop. Alas, today it cannot be found. However I found the following file on my Dropbox:
    meeting.rtf.sb-fecd476c-h4auul
    All I can think is that I saved it there but closed TextEdit and/or turned off my computer before it was done uploading. Is there any way of salvaging it from this?
    Thanks for any help,
    Jessi

    Hi,
    Sorry for late response since we are currently focusing on some high priority things.
    Regarding this issue, I can just give you some simple comments, 
    1) Can you clearly points out what occupied most of CPU time after using some profiling tool?
    2) IFSConnection-1 is a thread for processing the request from Finder/Explorer, JobHandler-x is the thread fro processing the request form Creative applications or Bridge.so I think the user must have openned one of them during saving the big file on the virtual drive.
    3) you dont't have to worry about the exception, it's just normal when saving a new file on the folder since AD doesn't cache it before. 

  • How to caluate sum at rtf file

    how can i caluate sum at group wise at rtf file
    let say i have table xx_table column is (vendor_no,vendor_site_code,invoce_date, inv_amt,....)
    i want to group vendor_site_code and i want to sum inv_amt at rtf file in site wise
    plz suggest

    Hi,
    You can do this from within your groupings in the data source file. Here's some example code showing hwo to do this.
    <group name="G_DEPT" source="Q1">
    <element name="DEPT_NUMBER" value="DEPTNO" />
    *<element name="DEPTSAL" value="G_EMP.SALARY" function="SUM()"/>*
    <group name="G_EMP" source="Q2">
    <element name="EMPLOYEE_NUMBER" value="EMPNO" />
    <element name="NAME" value="ENAME"/>
    <element name="JOB" value="JOB" />
    <element name="SALARY" value="SAL"/>
    </group>
    </group>
    Steve

  • How can I get an RTF file to open properly in MS Word?

    I'm using Coldfusion 8 and trying get it to export to Microsoft Word an RTF file  that was also created in Word, and is stored on the server. The problem is that when Word opens from the browser, it displays the RTF code for the document as if I'd opened the file in a text editor. The extension is ".rtf", and I've tried using ".doc" and ".docx" but nothing works. And even though Word opens it with an rtf extension, if I do a "Save As", it wants to save the file as an .htm file. I've also tried changing the content-type to "application/msword" but this didn't work. Also if I use OpenOffice instead of MS Word it still doesn't work. My code is below, if anyone could tell me what I'm doing wrong it would be very appreciated.
    <cfset formFile = "test.rtf">
    <cfset pathToRTF =  GetDirectoryFromPath(GetCurrentTemplatePath()) & formFile />
        <!---<cfset rtfForm = FileRead(pathToRTF) />--->
        <cffile
                action="read"
                file="#pathToRTF#"
                variable="rtfForm"
                >
    <cfcontent type="application/rtf">
    <cfheader name="Content-Type" value="application/rtf">
    <CFHEADER NAME="Content-Disposition" VALUE="filename=test.rtf">
    <cfoutput>
        #rtfForm#
    </cfoutput>

    What kind of local files are you trying to open and what kind of content is on the pages?
    Are that files that you've saved from the internet?

  • How do you format a numbers file that has been sent from excel?

    I have a report card that I have sent from a PC using excel to my air mac numbers program.  It sent it in four parts.  How do I format this?

    Denise,
    Select the cells, click the format icon to open the format panel, choose the cell tab and pick the format that you want to apply.
    Jerry

  • How do I stop Photoshop CS6 from asking to save changes to a file when closing the file, after "savi

    I save a lot of files to "save for web". After saving PS asks if I want to save changes to the original file. I never want to save the changes to the original. Since the default is to change the file I am afraid I will accidentally OK the change without wanting to. I would like it to stop asking and just not save it. Is there a way?

    Stephen Douge wrote:
    I never want to mess with originals. I am asking because I want to make sure I stated the question properly in the first place. Thanks.
    Then don't work on the original open the file using Photoshop menu file>open once its in Photoshop as a document dupe the document and close the original document. Photoshop will just close the original and not ask it you want to save the original document for no changes were made to it.  You could easily record an action to automate this process. The first step in the action would be an inserted menu item menu File>Open.  The second step Duplicate Document, third step select previous document the fourth and final step close. The action would look like this recorded Work in the dupe and save it under the name you want to where you want it saved. The First step is an interactive you will be able to open any file Photoshop has support for that you have access to.

  • How to tell script colse all files and save, but no untitle docs

    Hi everyone 
    I want to colse the open files and save them but no those files which have never been saved.
    I try this script but after ran, all the files are no be saved.
            var docs = app.documents;
                 for (var i = docs.length-1; i >= 0; i--) {
                     if(app.activeDocument.saved == false){
                           docs[i].close(SaveOptions.NO);
                     else if(docs[i].close(SaveOptions.YES));
    can someone tell me what's wrong with the script?
    thanks
    Regard
    Teetan

    var docs = app.documents;
    for (var i = docs.length-1; i >= 0; i--) {
        if (docs[i].saved == false) {
            docs[i].close(SaveOptions.NO);
        else {
            docs[i].close(SaveOptions.YES);

  • How can we format the download file as it is as report output.

    hi all,
    I have a issue, when i execute the program the the report output displays on output screen.
    now, in menu when i down load this output data into a word file the format is not correct i.e. it is not as it is in report output screen.
    how we can correct this output format, when we download in word format file through menu.
    pls help me on this .its very urgent.
    thanks!
    vipin

    Vipin,
    U will have to use OLE methods to format your MS-WORD output.
    Check the tcode  DWDM for sample code
    Also check out the threads:
    Get WORD Options with OLE
    Re: OLE and MS Word
    Also search in code samples with OLE-MSWORD
    Reward if helpful,
    Karthik

Maybe you are looking for