473,471 Members | 2,533 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Streams, Files, Readers and Writers

I evidently need to go back to remedial .Net class (I even 'Google'-ed this
and didn't come up with much), as it must be so easy that even a neophyte
could do it. So please help a neo-in-training!

I just want to read a text file into a MemoryStream so as to use the stream
for something else. I have instructions that work (I've tested them) for
the 'something else,' but I'm having severe trials with the
text-to-MemoryStream part. This is what I have (that's not working):

Dim sAppDir As String = Replace(Application.StartupPath(), "bin",
String.Empty)
Dim fileIn As New StreamReader(sAppDir & "Test1.xml")
Dim stream As New MemoryStream(fileIn.ReadToEnd.Length)
Dim writer As New StreamWriter(stream)
Dim fileOut As New StreamWriter(sAppDir & "Test1_Results.txt")

writer.Write(fileIn.ReadToEnd.ToString)

Thanx!

--
TFWBWY...A
Feb 9 '06 #1
2 936
YYZ
I honestly don't understand what you are trying to do...it looks like
you get your memorystream ok, except that you don't DO anything with it
-- I mean, you intialize it to hold all the text in the xml file, but
then never do anything with it...

Matt

Feb 9 '06 #2
Well, I said that I had some example code for the 'do-something-with-it'
part. But it's a mute point now, anyway, 'cause I figured it out and it's
working. It's truly amazing what a decent night's sleep will do for your
perspective...

"YYZ" <ma********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I honestly don't understand what you are trying to do...it looks like
you get your memorystream ok, except that you don't DO anything with it
-- I mean, you intialize it to hold all the text in the xml file, but
then never do anything with it...

Matt

Feb 10 '06 #3

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

Similar topics

27
by: Eric | last post by:
Assume that disk space is not an issue (the files will be small < 5k in general for the purpose of storing preferences) Assume that transportation to another OS may never occur. Are there...
2
by: Andy Leszczynski | last post by:
I need to now option I open the Berkley DB (both db and env) to have configuration for multiple writers and multiple readers. Via multiple processes and multiple threads. No trx needed. A.
8
by: bonj | last post by:
hello I hope somebody can help me get my head around this area of 'stream' programming... I know that streams are very fashionable nowadays so hopefully there'll be lots of replies. ;-) ...
11
by: Kobu | last post by:
I have a question about C's abstract "streams" (that I can't seem to FULLY understand from reading several tutorials). Streams seems to suggest that input can be treated continously if needed....
4
by: Toni | last post by:
Hi, I'm writing a C program that should do something like transactions on files. I have several reader processes and one writer, and I have to make sure that the writer either writes everything...
4
by: Ryan Liu | last post by:
TcpClient has a method called GetworkStream GetStream(); So in other words, there is only one stream associate with it for input and output, right? So while it is receiving, it can not send, and...
3
by: Kirit Sælensminde | last post by:
>From thread http://groups.google.com/group/comp.lang.c++/browse_thread/thread/79d767efa42df516 "P.J. Plauger" <p...@dinkumware.comwrites: I'll take this at face value and I'll have to suppose...
14
by: nathan.shair | last post by:
Hello, I searched on Google and in this Google Group, but did not find any solution to my problem. I'm looking for a way to output stdout/stderr (from a subprocess or spawn) to screen and to...
4
by: floppyzedolfin | last post by:
Hello! I'm actually encoding an encryption / decryption program. The encryption programes takes a file path in parameter, and encrypts the contents of the file and stores that into another file. ...
26
by: Bill Cunningham | last post by:
I have written this short program to empty out files. It works great except that it truncates. My guess was that it was in the fopen mode somewhere but I have played with that and the same results....
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.