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
openstreamwrite r = New StreamWriter(op enFileDialog1.F ileName)
If Not (myStream Is Nothing) Then
' Insert code to read the stream here.
myStream.Close( )
End If
End If 5 2455
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]
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:opse6jnh0b klbvpo@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]
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(openFileDial og1.ShowDialog( ) == DialogResult.OK )
{
StreamReader sr = new StreamReader(op enFileDialog1.F ileName);
rtb = sr.ReadToEnd();
sr.Close();
}
--
Happy coding!
Morten Wennevik [C# MVP]
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******@notre al.com> wrote in message
news:D5******** ************@co mcast.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
openstreamwrite r = New StreamWriter(op enFileDialog1.F ileName)
If Not (myStream Is Nothing) Then
' Insert code to read the stream here.
myStream.Close( )
End If
End If
Thank you, with your guys two posts I was able to get it working. : )
"Nick Malik" <ni*******@hotm ail.nospam.com> wrote in message
news:NId7d.1566 50$D%.81233@att bi_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******@notre al.com> wrote in message news:D5******** ************@co mcast.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
openstreamwrite r = New StreamWriter(op enFileDialog1.F ileName)
If Not (myStream Is Nothing) Then
' Insert code to read the stream here.
myStream.Close( )
End If
End If
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 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() =...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |