User (Old forums)MemberNovember 14, 2006 at 11:58 amPost count: 23064
I am trying to unzip a GZip’ed file I have in memory. I can sucessfully unzip the file that is saved to disk, back to disk… but how can I do this all in memory?
Basically my question is, where is the ToArrray() or GetStream() function on the MemoryFile class? How can I copy an array of bytes or MemoryStream to/from this MemoryFile object?
Thanks for any help
Imported from legacy forums. Posted by dmf (had 2725 views)User (Old forums)MemberNovember 14, 2006 at 12:18 pmPost count: 23064
Ok, I believe I have found my answer, however I am still having problems.
Apparently there is a FileStream class that we can integrate with IOStreams to accomplish my goal. However it is not working…
I have a single text file that is in a GZip archive. I want to write a function which takes this .gz file as an IO.MemoryStream, and then returns the contents of the text file contained in the zip via a String. The code looks like this:
Public Shared Function ExtractFileFromZip(ByVal inputStream As IO.MemoryStream) As String
Dim streamFile As New Xceed.FileSystem.StreamFile(inputStream)
Dim gzipFile As New Xceed.GZip.GZipArchive(streamFile)
Dim unzippedFile As Xceed.GZip.GZippedFile = CType(gzipFile.GetFiles(True)(0), Xceed.GZip.GZippedFile)
Dim ms As New IO.MemoryStream
Dim unzippedStream As New Xceed.FileSystem.StreamFile(ms)
See what I’m trying to do? I think I am very close, as the memory stream ‘ms’ DOES contain a valid AMOUNT of data. The problem is, this function is returning junk characters; garbage… Am I doing some encoding wrong or something?
BTW, I can unzip this file perfectly fine to disk. That code looks like this:
Dim gzipArchive As New Xceed.GZip.GZipArchive(New Xceed.FileSystem.DiskFile(“bulk.clear.gz”))
Dim gzipFile As Xceed.GZip.GZippedFile = CType(gzipArchive.GetFile(“equity_euro.px”), Xceed.GZip.GZippedFile)
Dim dest As New Xceed.FileSystem.DiskFile(“C:\TEMP.px”)
Any clue what could be the problem? How can I do this all in memory? I know I am close!!!
Thanks for any help.
Imported from legacy forums. Posted by dmf (had 322 views)User (Old forums)MemberNovember 14, 2006 at 1:45 pmPost count: 23064
note, this code DOES work… for some reason, with a very large file, Visual Studio craps out and shows me garbage as the contents… but with a small file, it works great… me thinks this is an issue with Visual Studio itself..
Imported from legacy forums. Posted by dmf (had 3513 views)
- You must be logged in to reply to this topic.