Bonjour a tout le monde.

J'ai un webservice en php qui compresse des fichiers dans une archive gzip.

Je les télécharge mais quand je veux les décompresser en VB.NET j'ai l'erreur suivante:
BAD MAGIC NUMBER

voici les code que j'utilise :

compression en php

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
 
$fl = fopen($path.$file,"rb");
$content = fread($fl, filesize($path.$file));
$gzData = gzcompress($content,9);
$fp = fopen($path.$file.".gz","wb");
fwrite($fp,$gzData);
fclose($fp);
return $file.".gz";
le code en VB pour decompresser et compresser

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
41
42
 
 Public Shared Function compresFile(ByVal source As String, ByVal destination As String) As Boolean
            Try
 
                Dim flstream As New FileStream(source, FileMode.Open)
                Dim outputFile As FileStream = File.Create(destination)
                Dim bufer(CInt(flstream.Length - 1)) As Byte
                flstream.Read(bufer, 0, CInt(flstream.Length))
                flstream.Close()
                Dim gzip As New GZipStream(outputFile, CompressionMode.Compress)
                gzip.Write(bufer, 0, bufer.Length)
                gzip.Close()
                Return True
            Catch ex As Exception
                Throw New Exception(ex.Message)
            End Try
 
 
        End Function
 
        Public Shared Function downloadFile(ByVal sourceFile As String, ByVal destinationFile As String) As Boolean
            Dim localStream As Stream
            Dim response As WebResponse
            Dim textWriter As StreamWriter
            'Dim fileinf As New FileInfo(destinationFile)
            'textWriter = fileinf.CreateText()
 
            Dim Request As WebRequest = WebRequest.Create(sourceFile)
 
            If Not Request Is Nothing Then
                response = Request.GetResponse()
                If Not response Is Nothing Then
                    localStream = response.GetResponseStream()
                    textWriter = New StreamWriter(destinationFile)
                    textWriter.AutoFlush = True
                    Dim strReader As New StreamReader(localStream)
                    Dim Query As String = strReader.ReadToEnd()
                    textWriter.Write(Query)
                End If
            End If
            textWriter.Close()
        End Function
je ne vois pas trop ou il y a une erreur. Pouvez vous m'aider merci.