|
-
Aug 30th, 2006, 05:18 PM
#1
Thread Starter
Arabic Poster
[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
-
Aug 30th, 2006, 05:29 PM
#2
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.
-
Aug 30th, 2006, 06:44 PM
#3
Thread Starter
Arabic Poster
Re: [2005] Streams question
 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
-
Aug 30th, 2006, 06:47 PM
#4
Thread Starter
Arabic Poster
Re: [2005] Streams question
FR is a FileStream (reader)
ES is a stream
FW is a FileStream (writer)
VB Code:
Dim BR As New System.IO.BufferedStream(Es)
Dim buffer(1024) As Byte
While FR.Position < FR.Length
FR.Read(buffer, 0, 1024)
BR.Write(buffer, 0, buffer.Length)
End While
Es.Close()
FR.Close()
While BR.Position < BR.Length
Dim X As Integer = BR.ReadByte()
If X <> -1 Then
FW.WriteByte(CByte(X))
End If
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|