Results 1 to 4 of 4

Thread: [2005] Streams question

  1. #1

    Thread Starter
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    [2005] Streams question

    Hi everyone

    What kind of streams do I need to use to copy large files into a memory stream, process the data and copy it to a new file?
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: [2005] Streams question

    well i am not sure, but i will say use System.IO.BufferedStream . Because it works most like MemoryStream and it is constructed or initialised to some other existing Stream, in your case it could be a Text file, so you wont require external writing to a file using FileStream.

    just my 2 cents.
    Show Appreciation. Rate Posts.

  3. #3

    Thread Starter
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: [2005] Streams question

    Quote Originally Posted by Harsh Gupta
    well i am not sure, but i will say use System.IO.BufferedStream . Because it works most like MemoryStream and it is constructed or initialised to some other existing Stream, in your case it could be a Text file, so you wont require external writing to a file using FileStream.

    just my 2 cents.
    How would I write into the buffer synchronously if the BufferedStream doesn't support seeking
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  4. #4

    Thread Starter
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: [2005] Streams question

    FR is a FileStream (reader)
    ES is a stream
    FW is a FileStream (writer)
    VB Code:
    1. Dim BR As New System.IO.BufferedStream(Es)
    2.             Dim buffer(1024) As Byte
    3.             While FR.Position < FR.Length
    4.                 FR.Read(buffer, 0, 1024)
    5.                 BR.Write(buffer, 0, buffer.Length)
    6.             End While
    7.             Es.Close()
    8.             FR.Close()
    9.             While BR.Position < BR.Length
    10.                 Dim X As Integer = BR.ReadByte()
    11.                 If X <> -1 Then
    12.                     FW.WriteByte(CByte(X))
    13.                 End If
    14.             End While
    in case the code helps you, the problem is the BufferedStream doesn't support seeking and I don't know what kind of stream to use

    EDIT: I decided not use the MemoryStream
    Last edited by ComputerJy; Aug 30th, 2006 at 06:52 PM.
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width