Re: Reading & Writing in a Stream

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 03/07/04


Date: Sun, 7 Mar 2004 17:17:58 -0000

Cor <non@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.GetBytes 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 - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Re: File Streams
    ... >one line at a time to a disk file and making it comma delimeted at the same ... > I know I could store pointers for the positon I'm at in the array, ... >working array then dump it it may be faster and less hassles, or a stream. ... Generally I have found that the optimum speed is obtained by writing ...
    (alt.comp.lang.borland-delphi)
  • Email Attachment
    ... i have a file read in a stream ... and without writing it to disk i want to send it as an attachement, ... Prev by Date: ...
    (microsoft.public.dotnet.languages.csharp)
  • Streams
    ... I have a typical text file that I have been writing to disk. ... routines that support compressing streams then writing to disk. ... Are there any simple examples how to write a text file to a Stream? ...
    (alt.comp.lang.borland-delphi)
  • Re: Reading & Writing in a Stream
    ... Cor wrote: ... write bytes to disk, one way or other. ... I still say it's irrelevant whether or not the OP's stream is writing ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: LVM write performance
    ... it and finally write it back to the disk. ... noop [deadline] cfq ... Writing 1 GB ... AACRAID* Controller on a Supermicro. ...
    (Debian-User)