473,490 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Memorystream

Hi group,

I am trying to decipher MemoryStream. I need to read the contents of a text
file to memory line by line, process each line and the output the line to a
new text file.

However, it is proving a bit painful trying to work out how to do this with
memorystream. Any chance someone could post some sample code or give
pointers?

Thanks.

--

I'll have a B please Bob.
Nov 21 '05 #1
7 1724
Bob,

For this is the memorystream not build. The memorystream is to make
streaming possible without the need to write it to an extern medium and visa
versa.

You are doing string manipulations (You reed a file, take from a everytime
new starting point until the vbcrlf a string and goes on like that). However
that is as well not the most easy way when you do that in memory with a
complete file.

Doing this in in my opinion most effective way is using the arraylist or
direct.

pseudo with the arraylist

dim ar as new arraylist
Reading etc
ar.add(rdr.readline)

Processing
for i as integer = 0 to arr.length - 1
proces
write
next

However the best way is ofcourse to incorporate all in one reading and
writing of line process using the streamreader and streamwriter

I hope this helps?

Cor
Nov 21 '05 #2
Bob,

I forgot, when you have that text allready in memory, you can use the split
with the vbcrlf to make an array of that.

Cor
Nov 21 '05 #3
Cor, maybe he did not make himself clear. I understand it as:

he wants to load a text file into memory. Keep it there for a while, then
as he streams it back to file, add/change the information and then write the
line.

Is it better not to use memorystream for this? I am also looking for the
answer to this!!! ;-)

--

Daniel
MCSE, MCP+I, MCP in Windows 2000/NT

--------------------------------------
remove the 2nd madrid from my mail address to contact me.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Bob,

I forgot, when you have that text allready in memory, you can use the
split with the vbcrlf to make an array of that.

Cor

Nov 21 '05 #4
Daniel,

It makes no sense to use the memorystream here.

That is for processes where are no other alternatives than streaming, as
encoding for security or encoding to make it another (file) format.

In yours and Bobs case you are doing string manipulations, wherefore are a
lot of better methods.

I hope this clears it a little bit?

Cor
Nov 21 '05 #5
Oh ok. I got it now! What can you suggest as an alternative? Mine is with
a text file containing maybe 300 filenames and paths. I want to read them
in. Use them and then output them with a change later.

Thanks

--

Daniel
MCSE, MCP+I, MCP in Windows 2000/NT

--------------------------------------
remove the 2nd madrid from my mail address to contact me.

"Cor Ligthert" <no************@planet.nl> wrote in message
news:Ov**************@TK2MSFTNGP09.phx.gbl...
Daniel,

It makes no sense to use the memorystream here.

That is for processes where are no other alternatives than streaming, as
encoding for security or encoding to make it another (file) format.

In yours and Bobs case you are doing string manipulations, wherefore are a
lot of better methods.

I hope this clears it a little bit?

Cor

Nov 21 '05 #6
Daniel,

When you are sure it are lines than you can either set them in a listbox, or
a texbox (in multiline mode, that changes the behaviour because it takes
real lines) or even better in a listview. In that listbox you read them as
lines and that textbox you can read it as file, while in the listview (which
is probably the best for your problem, think on explorer) you read them and
process them. That listview is slow when you update it, so set the edit mode
to on. (It is in fact than the right pane of explorer, there are a lot of
samples for that)

There it can be changed. When it has not to be on screen set them in an
arraylist of objects (while I would use a datatable, just because that is
for me easy to handle) as I told while reading.
When it is really needed I will make a very small sample, with the datatable
and show that than in a datagrid however it is dead simple.

However when you want a sample, than show first the structure of that file
textfile because I assume it is CSV and that can even in one time using
OleDB.
Cor
Nov 21 '05 #7
A String? :)
Nov 21 '05 #8

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

Similar topics

1
11112
by: xmlguy | last post by:
PREVIOUS BACKGROUND POST: I am trying to reuse a Memory Stream for loading and transforming the xml it contains Basically I have defined following interfaces: Class Render {
3
10933
by: Nicolas | last post by:
Hi Everybody, I'm working with the MemoryStream and I'm having problems with the ReadBytes method. When I use it, this method never returns bytes!!!! MemoryStream sw = new MemoryStream();...
2
2114
by: SQLScott | last post by:
For some reason I am drawing a blank on this, so I would be extremely greatful if someone could help me out. I am trying to get a MemoryStream out of a Byte array. How do I get it back out? ...
4
8407
by: Heron | last post by:
Hi, Could someone explain me why the following code doesn't work? The memorystream always remains with length 0. MemoryStream input = new MemoryStream();
3
5516
by: =?Utf-8?B?UGhpbCBKb2huc29u?= | last post by:
Hi, I am using dotnet remoting with a binarry formatter. I have a property that returns a memorystream that has had a file loaded into it. When I try to access this property though I get an...
0
7112
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
6974
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
7146
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
7183
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
6852
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...
1
4878
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
4573
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
3084
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
277
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.