iskiskisk

hi

how r u

i want to make programe can load txt files to textbox

how

Go0d ByE




Re: Visual C# General i want to load txt file to my programe

iskiskisk

up






Re: Visual C# General i want to load txt file to my programe


Re: Visual C# General i want to load txt file to my programe

iskiskisk

can u give me another one






Re: Visual C# General i want to load txt file to my programe

iskiskisk

uuuuuuuuuuppppppppp






Re: Visual C# General i want to load txt file to my programe

sirjis

Here you go.

Oh, and this may be useful for you in the future. If you want people to put more time into answering your questions, put more time into asking them.




Re: Visual C# General i want to load txt file to my programe

Pink Splat

Alright to load an already existing .txt file into a textbox you should be able to use something along the lines of:

Code Snippet

using System;

using System.Windows.Forms;

using System.IO;

namespace LoadTest

{

public partial class Form1 : Form

{

private string fileName = "";

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

DialogResult result = openFileDialog1.ShowDialog();

//Makes sure that the file is actually there

if (File.Exists(openFileDialog1.FileName))

{

fileName = openFileDialog1.FileName;

}

//If OK is pushed in the file dialog

if (result == DialogResult.OK)

{

StreamReader sr = new StreamReader(fileName);

textBox1.Text = sr.ReadToEnd();

sr.Close();

}

} //Ends button1_click

} //Ends Partial Class

} //Ends namespace

Hopefully this helps. If you are using a RichTextBox instead you don't need to use the StreamReader but instead you can use "richTextBox1.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);"