2 Replies - 1239 Views - Last Post: 03 January 2010 - 12:02 PM Rate Topic: -----

#1 CreaturGames   User is offline

  • D.I.C Regular

Reputation: 30
  • View blog
  • Posts: 290
  • Joined: 29-December 09

C# Inserting text from two richTextBoxes into one file and reopening

Posted 03 January 2010 - 11:52 AM

Well, C# Inserting text from two richTextBox's into one file and reopening the files and putting the text into its original richtextbox's. Heres my code:

SaveFileDialog savedialog = new SaveFileDialog();
savedialog.Filter = "Code Project File|*.cpf";


if(savedialog.ShowDialog() > System.Windows.Forms.DialogResult.OK)
{
	richTextBox1.SaveFile(savedialog.FileName, 
		RichTextBoxStreamType.PlainText);
	richTextBox2.SaveFile(savedialog.FileName + ".txt",
		 RichTextBoxStreamType.PlainText);
}




And heres the code for opening the two as one project


OpenFileDialog opendialog = new OpenFileDialog();
opendialog.Filter = "Code Project File|*.cpf";


if(opendialog.ShowDialog() > System.Windows.Forms.DialogResult.OK)
{
	richTextBox1.LoadFile(opendialog.FileName, 
		RichTextBoxStreamType.PlainText);
	richTextBox2.LoadFile(opendialogFileDialog1.FileName + ".txt",
		 RichTextBoxStreamType.PlainText);
}



This wouldn't work out well because if you moved the txt file somewhere else, it would come up with exceptions.

Could you help?

This post has been edited by CreaturGames: 03 January 2010 - 11:53 AM


Is This A Good Question/Topic? 0
  • +

Replies To: C# Inserting text from two richTextBoxes into one file and reopening

#2 Theaegd   User is offline

  • Hater & Lover

Reputation: -125
  • View blog
  • Posts: 944
  • Joined: 15-August 09

Re: C# Inserting text from two richTextBoxes into one file and reopening

Posted 03 January 2010 - 11:58 AM

you could save the text of the boxes (richtextbox1.Text) into seperate strings, and then display next to eachother. That gets rid of the saving, obviously unless you need the saving.
Was This Post Helpful? 1
  • +
  • -

#3 CreaturGames   User is offline

  • D.I.C Regular

Reputation: 30
  • View blog
  • Posts: 290
  • Joined: 29-December 09

Re: C# Inserting text from two richTextBoxes into one file and reopening

Posted 03 January 2010 - 12:02 PM

So basically it would be like a simple mini database, which the richTextBoxs would pull the text from certain parts of the database. I get it. :D

Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1