| View previous topic :: View next topic |
| Author |
Message |
Deve Expert Cheater
Reputation: 0
Joined: 20 Jan 2007 Posts: 245 Location: Stockholm, Sweden
|
Posted: Fri Feb 06, 2009 4:16 pm Post subject: [C#] File management |
|
|
Hi again, Im making an lightweight text/file editor.
My idea is simply open an .txt file, display it in editable view and be able to same that file.
I succeeded with making the open&save buttons but im really stuck on the text editing window:
What tool should i use for it? What code should it be behind it to work?
I search on google but haven't found eny sources/tutorials that fit my demands.
Regards,
Deve
_________________
Leecher. |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Fri Feb 06, 2009 11:38 pm Post subject: |
|
|
| I doubt you'll do better than the RichTextEdit control outside of creating your own.
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Sat Feb 07, 2009 2:55 pm Post subject: Re: [C#] File management |
|
|
| develito wrote: | Hi again, Im making an lightweight text/file editor.
My idea is simply open an .txt file, display it in editable view and be able to same that file.
I succeeded with making the open&save buttons but im really stuck on the text editing window:
What tool should i use for it? What code should it be behind it to work?
I search on google but haven't found eny sources/tutorials that fit my demands.
Regards,
Deve |
Hi.
Normal textbox = plain text editing
Rich textbox = For when you need special formation on one or more paragraphs.
Easiest code to read from and write to files :
| Code: |
private void Loadbtn_Click(object sender, EventArgs e)
{
textBox1.Text = File.ReadAllText(@"C:\test.txt");
}
private void Savebtn_Click(object sender, EventArgs e)
{
File.WriteAllText(@"C:\test.txt", textBox1.Text);
} |
Sometimes you might wanna read all the lines seperatly
| Code: |
foreach (string line in File.ReadAllLines(@"C:\test.txt"))
{
textBox1.Text += line;
} |
Futhermore you might wanna study streamreaders, streamwriters, filedialogs and later on rich textboxes.
Best of luck /wireen.
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
|