473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

openfiledialog for text editor

hi,

i have an openfiledialog and a multiline textbox. i want to be able to open
text documents in it. can you please give me the c# code to do this?

by the way, the textbox is called textBox1 and the openfiledialog is called
openFileDialog1

--
Alvo von Cossel I of Germany
Nov 17 '05 #1
2 1995
Alvo,

Once you get the name of the file from the file dialog, you will want to
use the StreamReader class to read the contents of the file into a string
(through the methods on the StreamReader, most notably, ReadToEnd). Once
you do that, you can set the Text property of the textbox to the string and
the contents will be in there.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alvo von Cossel I" <Al************@discussions.microsoft.com> wrote in
message news:23**********************************@microsof t.com...
hi,

i have an openfiledialog and a multiline textbox. i want to be able to
open
text documents in it. can you please give me the c# code to do this?

by the way, the textbox is called textBox1 and the openfiledialog is
called
openFileDialog1

--
Alvo von Cossel I of Germany

Nov 17 '05 #2
hi,

i am very new to c# and i'd be grateful if you answered in a little less
technical terms. by the way, where it says it answered my question, it
didn't. i clicked the wrong button

--
Alvo von Cossel I of Germany
"Nicholas Paldino [.NET/C# MVP]" wrote:
Alvo,

Once you get the name of the file from the file dialog, you will want to
use the StreamReader class to read the contents of the file into a string
(through the methods on the StreamReader, most notably, ReadToEnd). Once
you do that, you can set the Text property of the textbox to the string and
the contents will be in there.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Alvo von Cossel I" <Al************@discussions.microsoft.com> wrote in
message news:23**********************************@microsof t.com...
hi,

i have an openfiledialog and a multiline textbox. i want to be able to
open
text documents in it. can you please give me the c# code to do this?

by the way, the textbox is called textBox1 and the openfiledialog is
called
openFileDialog1

--
Alvo von Cossel I of Germany


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jody Gelowitz | last post by:
VS.NET 2002 and 2003 are installed. ..NET Framework 1.0 and 1.1 installed Program running under VisualBasic.NET 2002 with .NET Framwork 1.0 I am experiencing a problem with ADO.NET where the...
3
by: bobrad | last post by:
MAYBE SOMEBODY CAM HELP I AM USING THE FOLLOWING CODE TO GET A LOCATION OF A FILE IN A WINFORM DIALOG OpenFileDialog openFileDialog = new OpenFileDialog(); OpenFileDialog.Filter = " Access...
4
by: Nagachandra Sekhar Grandhi | last post by:
I am facing a problem with OpenFileDialog. It is as follows. I opened OpenFileDialog dialog box and selected a folder in it. After selecting the folder when i tried to delete the same folder in...
0
by: Dmitriy Kolesnik | last post by:
Hello, All! I develop Registry Editor - copy of the standard Registry Editor. In standard Registry Editor exists dialog "Export Registry File" (File -> Export...) (see attach). Some controls...
3
by: josh | last post by:
How do I make it actually save or open a file? It only opens the dialogs. What do I type to get it to save? Here's what I have so far: Public Class frmMainApp Inherits...
0
by: Gregaz | last post by:
I have a form in my project, which I open as a DialogBox. On that that form there are 3 TextBoxes. To one of them I want to write in a file path. To have it easier I have an OpenFileDialog control...
6
by: Mike | last post by:
Hello all, I'm trying to work with the openfiledialog and being new to vb and vb.net I'm having some problems. Wherever I have Me.OpenFileDialog1 I keep getting the following error: C:\Visual...
4
by: NickP | last post by:
Hi there, This is really crazy! 1. Make a folder 2. Put a text file in the folder 3. Run the following code... Dim pop As New OpenFileDialog Using pop
3
by: Tony Johansson | last post by:
Hello! The object called dlgOpenFile is of type OpenFileDialog. In this example the eventhandler OnFileOpen is called when the Open File in a menu is clicked. Here we call the OpenFileDialog...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.