473,396 Members | 1,895 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,396 software developers and data experts.

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 2445
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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
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...

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.