Question Byte Array to TFilestream

p_nivalis

Active member
Joined
Oct 1, 2004
Messages
33
Programming Experience
5-10
Hello,
i have a Project where i want to compress / decompress with gzipstream
at decompress i have a problem:

VB.NET:
'blabla much more code...

'Read the size of compressed stream.
                ZIPFSI.Position = ZIPFSI.Length - 4
                ZIPFSI.Read(sizeBytes, 0, 4)

                Dim iOutputSize As Integer = BitConverter.ToInt32(sizeBytes, 0)

                'Posistion the to point at beginning of the memory stream to read
                'compressed stream for decompression.

                ZIPFSI.Position = 0

                Dim B2(iOutputSize - 1) As Byte

                'Read the decompress bytes and write it into result byte array.
                Dim BytesRead2 As Integer = GZipStream2.Read(B2, 0, iOutputSize)

now i have B2 as byte array and i have to convert this into Filestream!
i tried to convert it first to Memory stream, that works
bt i cant convert memory stream to filestream!

what should i do?

here are the errors:
Fehler 1 Der Wert vom Typ "System.IO.MemoryStream" kann nicht in "System.IO.FileStream" konvertiert werden.

or:
Fehler 1 Der Wert vom Typ "1-dimensionales Array von Byte" kann nicht in "System.IO.FileStream" konvertiert werden.
was tun?
 
thx for answer!

I have to use a function in a class
Public Function ReadOut(ByVal Link As String, Optional ByVal entzip As Boolean = False) As FileStream

so the result MUST be a filestream
 
Well, as you are finding, you dont convert MemoryStreams into filestreams any more than you convert your Cat into a Bike when you want to ride to the shops.


We're gonna need to se emore code, but the other guy is right.. you should be reading/writing your FileStream, not attempting to convert it
 
Back
Top