473,499 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

openfiledailog

Jay
First I want to say thanks for the help on my previous post. I got the save
to work. But now I am working on the open and when I open a file it comes
up blank in my rich text box and then I go and look at the file it to is
blank. I tried to use the help file and no matter what I do it comes up
blank. This is what I have left, what am I missing here? BTW this code is
straight from the help file.

If openFileDialog1.ShowDialog() = DialogResult.OK Then

openstreamwriter = New StreamWriter(openFileDialog1.FileName)

If Not (myStream Is Nothing) Then

' Insert code to read the stream here.

myStream.Close()

End If

End If
Jul 21 '05 #1
5 2447
Hi Jay,

A StreamWriter writes data to a stream/file. If you want to read the file, use a StreamReader.

--
Happy coding!
Morten Wennevik [C# MVP]
Jul 21 '05 #2
Jay
I was thinging that and I tried to code it with reader and it did not work.
"Morten Wennevik" <Mo************@hotmail.com> wrote in message
news:opse6jnh0bklbvpo@stone...
Hi Jay,

A StreamWriter writes data to a stream/file. If you want to read the
file, use a StreamReader.

--
Happy coding!
Morten Wennevik [C# MVP]

Jul 21 '05 #3
Jay,

If you have a file called MyFile.txt
and a RichTextBox called rtb you would typically do something like.

C# code but it shouldn't be hard to translate to VB

StreamReader sr = new StreamReader("C:\\MyFile.txt");
rtb.Text = sr.ReadToEnd();
sr.Close();

Using a OpenFileDialog you could do something like.

if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
StreamReader sr = new StreamReader(openFileDialog1.FileName);
rtb = sr.ReadToEnd();
sr.Close();
}
--
Happy coding!
Morten Wennevik [C# MVP]
Jul 21 '05 #4
Hi Jay,

OK... you have the code to open the file and the code to close it... did you
comment out the code to read the file from your posting, or perhaps, you
don't have any code in your app that actually reads the file?

http://support.microsoft.com/default...b;en-us;315828

--- Nick

"Jay" <fr******@notreal.com> wrote in message
news:D5********************@comcast.com...
First I want to say thanks for the help on my previous post. I got the save to work. But now I am working on the open and when I open a file it comes
up blank in my rich text box and then I go and look at the file it to is
blank. I tried to use the help file and no matter what I do it comes up
blank. This is what I have left, what am I missing here? BTW this code is straight from the help file.

If openFileDialog1.ShowDialog() = DialogResult.OK Then

openstreamwriter = New StreamWriter(openFileDialog1.FileName)

If Not (myStream Is Nothing) Then

' Insert code to read the stream here.

myStream.Close()

End If

End If

Jul 21 '05 #5
Jay
Thank you, with your guys two posts I was able to get it working. : )
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message
news:NId7d.156650$D%.81233@attbi_s51...
Hi Jay,

OK... you have the code to open the file and the code to close it... did
you
comment out the code to read the file from your posting, or perhaps, you
don't have any code in your app that actually reads the file?

http://support.microsoft.com/default...b;en-us;315828

--- Nick

"Jay" <fr******@notreal.com> wrote in message
news:D5********************@comcast.com...
First I want to say thanks for the help on my previous post. I got the

save
to work. But now I am working on the open and when I open a file it
comes
up blank in my rich text box and then I go and look at the file it to is
blank. I tried to use the help file and no matter what I do it comes up
blank. This is what I have left, what am I missing here? BTW this code

is
straight from the help file.

If openFileDialog1.ShowDialog() = DialogResult.OK Then

openstreamwriter = New StreamWriter(openFileDialog1.FileName)

If Not (myStream Is Nothing) Then

' Insert code to read the stream here.

myStream.Close()

End If

End If


Jul 21 '05 #6

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

Similar topics

5
356
by: Jay | last post by:
First I want to say thanks for the help on my previous post. I got the save to work. But now I am working on the open and when I open a file it comes up blank in my rich text box and then I go...
0
7005
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...
1
6891
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7381
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5465
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4916
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1424
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
659
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
293
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.