Advertisement
Advertisement
| 08.12.2008 at 01:54AM PDT, ID: 23640504 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: |
Public Shared Function DecompressorZippedFile(ByVal filename As String) As Stream
msg = "Test decompression on file " & filename
MsgBox(msg)
Dim infile As FileStream
Try
' Open the file as a FileStream object.
infile = New FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim buffer(infile.Length - 1) As Byte
' Read the file to ensure it is readable.
Dim count As Integer = infile.Read(buffer, 0, buffer.Length)
If count <> buffer.Length Then
infile.Close()
msg = "Test Failed: Unable to read data from file"
MsgBox(msg)
Return Nothing
End If
Dim zipStream As New GZipStream(infile, CompressionMode.Decompress)
'MsgBox("zip stream length " & zipStream.Length) 'System.NotSupportedException
Dim decompressedBuffer(buffer.Length + buffer_size) As Byte
' Use the ReadAllBytesFromStream to read the stream.
Dim totalCount As Integer = ReadAllBytesFromStream(zipStream, decompressedBuffer)
msg = "Decompressed " & totalCount & " bytes"
MsgBox(msg)
If Not CompareData(buffer, buffer.Length, decompressedBuffer, totalCount) Then
msg = "Error. The two buffers did not compare."
MsgBox(msg)
End If
infile.Close()
Return infile
Catch e As Exception
msg = "Error: The file being read contains invalid data."
MsgBox(msg)
Return Nothing
End Try
End Function
|