ok, this is really strange.
I made a simple text editor(all it is is a rich txt box,open button,and save button). I can save normally, and I can read text files I created using notepad normally. One problem though: I can read text files created using notepad, wordpad, ect, but I cannot read text files created by my program! When I try to open files created by this program, it only reads the first character.
Heres my open file routine:
//class variables, only listing the ones that matter.
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.Button button2;
void Button2Click(object sender, System.EventArgs e)
{
if(openFileDialog1.ShowDialog()==DialogResult.OK)
{
if((openFileDialog1.OpenFile())!=null)
{
StreamReader str=new StreamReader(openFileDialog1.FileName);
richTextBox1.Text=str.ReadToEnd();
str.Close();
}
}
}
and here is my save file routine:
void Button1Click(object sender, System.EventArgs e)//button1 is also declared.
{
Stream s;
if(saveFileDialog1.ShowDialog()==DialogResult.OK)
{
if((s=saveFileDialog1.OpenFile())!=null)
{
byte[] arr=new byte[5000];
arr=stringtobyte(richTextBox1.Text);
int size=arr.Length;
s.Write(arr,0,size);
s.Close();
}
}
}
so whats my problem?
EDIT:
I know the indenting is kinda screwed, sharpdevelop does not copy very well.
[Edited by - supercoder74 on June 29, 2005 1:36:54 PM]
I program in my sleep,but when I sleep I use the partition in my head that doesnt have g++ or the .net library, so im kinda screwed.