|
-
January 18th, 2008, 01:47 AM
#1
Save txt and img to one file using an rtf box
I am trying to save a file that has an image pasted in along with the text that is typed. I have been able to get the text to save with no problem but the image pasted in is not saving.
here is the code I am using:
string path1 = cmbCat.Text;
FileStream fs = new FileStream("\\BOS\\Cat\\" + path1 + "\\" + textBox1.Text + ".wri", FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);
sw.Write(txtBox1.Text);
sw.Flush();
sw.Close();
fs.Close();
it saves the text just find but does not save the image. What can i do and how?
-
January 18th, 2008, 01:57 AM
#2
Re: Save txt and img to one file using an rtf box
Does *.wri format supports image ?
Regards,
MMH
Rate my post if you find it usefull. 
-
January 18th, 2008, 02:20 AM
#3
Re: Save txt and img to one file using an rtf box
Of course it saves only the text. That's what a StreamWriter is for: to write text. Look at this:
Code:
sw.Write(txtBox1.Text);
You're specifically writing the text. If you want to save an image then you have to save to a format that supports images. The RichTextBox is named as it is because is supports Rich Text Format. If you want to save all the formatting, images, etc. in the RichTextBox then you need to save the RTF code it contains. RTF code is somewhat like HTML code, and a RichTextBox is somewhat like a Web browser. It takes the code and renders it to a formatted output.
I suggest that you read the MSDN documentation for the RichTextBox control so you understand how it works. In doing so you'll encounter its SaveFile and LoadFile methods, which allow you to save and load files in one line of code to either plain text or RTF format.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|