473,796 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading & Writing in a Stream

Ali
Hi

I want to write (or read) to a stream, but the data is not byte array
I converted the data to byte array manually, but it is very slow, (becuse the data is very large)
Is another way for this kind of writing and reading

best regard
Ali.
Nov 15 '05
16 9114
Cor
Hi Jon,

I forgot to thank you for this greath answer.
(I missed something from your previous post, btw - a Stream*Reader*
doesn't write *anything* - it only *reads*.)


I hope that I do not disappoint you, when I tell you that I did know that
already but made a typo.

:-)

Cor
Nov 15 '05 #11
Cor <no*@non.com> wrote:
A newsgroup keep the messages open this is what you tell that is the
question from the OP
The OP wants to know how to write data to a *stream*, so he can't do it
as strings - not without a StreamWriter or manually calling
Encoding.GetByt es etc.


This is the question from the OP (copied from his message)
I want to write (or read) to a stream, but the data is not byte array.
I converted the data to byte array manually, but it is very slow, (becuse
the data is very large).
Is another way for this kind of writing and reading?
---------------------------------------------------------
I do not know if he means to mem. to http or to disk. Therefore I gave the
answer that if it is to disk, it is not necessary to make first that
bytearray.


Why though? How would you do things differently if it's writing to a
disk compared with writing anywhere else?
I did not tell how, that could be done when he had asked for that or maybe
he had answered that it was not to disk and than I had given another answer.


Well, you said you could write strings directly using a stream, which
you can't - you need to wrap it with a StreamWriter first, and that's
true whether the stream is to memory, the network or wherever.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #12
Cor
Hi Jon,

Well, you said you could write strings directly using a stream, which
you can't - you need to wrap it with a StreamWriter first, and that's
true whether the stream is to memory, the network or wherever.


Show me where I wrote that above, this is the X th time you are telling from
people what they said, while they did not.

So copy it where I wrote that and show it.

But as usualy you answer this not anymore because you cannot.

Cor
Nov 15 '05 #13
Cor <no*@non.com> wrote:
Well, you said you could write strings directly using a stream, which
you can't - you need to wrap it with a StreamWriter first, and that's
true whether the stream is to memory, the network or wherever.


Show me where I wrote that above, this is the X th time you are telling from
people what they said, while they did not.

So copy it where I wrote that and show it.

But as usualy you answer this not anymore because you cannot.


My mistake, you didn't use the word "directly". However, you did say:

<quote>
Are you talking about a stream to disk, than you can just do it as
strings.
</quote>

Which you can't. You can't (directly - my word) write a string to a
stream. You *have* to go through a conversion process (which is what
the OP apparently wanted to avoid) whether that's done directly using
Encoding or using StreamWriter. It doesn't matter whether you're
writing to a disk or not.

Your post gave the impression (to me at least) that you thought you
could write strings directly to a stream, which you can't.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #14
Cor
Hi Jon,

Your post gave the impression (to me at least) that you thought you
could write strings directly to a stream, which you can't.


Did you see me write here that I thought that you said that it was only
possible to write bytearrays to disk?

That I could have been writing very easy by what you where telling and than
telling to you that you can only write bytes to a disk.

I expect that you know those basic things.
Cor
Nov 15 '05 #15
Cor <no*@non.com> wrote:
Your post gave the impression (to me at least) that you thought you
could write strings directly to a stream, which you can't.
Did you see me write here that I thought that you said that it was only
possible to write bytearrays to disk?


No, I didn't - but that's basically true. Of course, you can *convert*
strings to byte arrays using StreamWriter, but it's still going to
write bytes to disk, one way or other.
That I could have been writing very easy by what you where telling and than
telling to you that you can only write bytes to a disk.


Sorry, could you rephrase that? I didn't understand that sentence.

I still say it's irrelevant whether or not the OP's stream is writing
to disk though.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #16
Cor
Jon,

No, I didn't - but that's basically true. Of course, you can *convert*
strings to byte arrays using StreamWriter, but it's still going to
write bytes to disk, one way or other.
That I could have been writing very easy by what you where telling and than telling to you that you can only write bytes to a disk.


Sorry, could you rephrase that? I didn't understand that sentence.


Not needed see the phrase of you before that, the meaning is almost exactly
the same.

Cor
Nov 15 '05 #17

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

Similar topics

4
9844
by: Oliver Knoll | last post by:
According to my ANSI book, tmpfile() creates a file with wb+ mode (that is just writing, right?). How would one reopen it for reading? I got the following (which works): FILE *tmpFile = tmpfile(); /* write into tmpFile */ ...
1
26815
by: andrewcw | last post by:
OK I am half way there - I can manipulate the stream without the byte issue like this - but is this the way to push the new values back into the stream & write out the stream without resorting to byte conversion ?? FileStream stream = null; stream = File.Open(fiPath, FileMode.Open, FileAccess.ReadWrite,FileShare.None); System.IO.StreamReader Tin = new System.IO.StreamReader (stream);
3
9515
by: Nick | last post by:
I have found a class that compresses and uncompresses data but need some help with how to use part of it below is the deflate method which compresses the string that I pass in, this works OK. At the end of this message is the inflate method this is where I get stuck I know that I need a byte array but because I am decompressing a string I have no idea of how big the byte array will need to be in the end (the inflate and deflate methods...
6
44124
by: Neil Patel | last post by:
I have a log file that puts the most recent record at the bottom of the file. Each line is delimited by a \r\n Does anyone know how to seek to the end of the file and start reading backwards?
21
13106
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the server is on one line (\r\n at end) and is formed as - each of which is seperated by a space. Arguments with spaces in them are enclosed in quotations. So, I'm able to open a connection to the server. When I send a message to
1
2910
by: KWSW | last post by:
Got a question about reading and writing binary files. I know that to write a value(integer) to a binary file I can use the fileoutputstream to do it. try { // Create an output stream to the file. FileOutputStream file_output = new FileOutputStream (outFile); //for(int i = 0; i < cInt.length; i++)
0
4729
by: Vinod Sadanandan | last post by:
STANDBY DATABASE MONITORING & PROTECION MODES (9iR2) This document is written for understanding and monitoring standby database configured with diffrent protection modes . MAXIMUM PROTECTION -Guarantees that no data loss will occur if the primary database fails. To provide this level of protection, the redo data needed to recover each transaction must be written to both the local online redo log and to a standby redo log on at least...
1
2132
by: Sebarry | last post by:
Hi, I'm trying to read the results of a database query into an XML document but it's only read so far and stopping. The XML document is as follows: <?xml version="1.0" encoding="utf-8"?> <night> <name>Poontang</name>
21
3071
by: Stephen.Schoenberger | last post by:
Hello, My C is a bit rusty (.NET programmer normally but need to do this in C) and I need to read in a text file that is setup as a table. The general form of the file is 00000000 USNIST00Z 00000000_00 0 000 000 000 0000 000 I need to read the file line by line and eventually parse out each piece of the file and store in arrays that correspond to the specific
0
9528
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,...
0
10455
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10228
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10006
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 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...
0
9052
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, 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...
1
7547
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 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...
0
6788
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();...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2925
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 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...

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.