Posted: Sun Nov 22, 2009 8:20 pm Post subject: [C#] TextReader & StreamReader
Well I would like to Write the info of Textbox1.text into a text file called Settings.txt, and then I want it to load the current Settings.txt into TextBox1 if I Press "Load". I got the Writing to the text file down, but not the reading of the file = textBox1.text.
Here is the whole code:
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace TextFileWriter
{
public partial class Form1 : Form
{
using (StreamReader sr = new StreamReader(Directory.GetCurrentDirectory() + "\\Settings.txt"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
textBox1.Text += line + Environment.NewLine;
}
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum