برای فشارده ساز داخل دات نت میتونی از کلاس مربوط به فشرده سازی استفاده کنی
کد:
' Open the input file as a FileStream object.
stmInFile = New FileStream(pFileName, FileMode.Open)
' Open the output file as a FileStream object.
stmOutFile = New FileStream(pFileName + strExtension, FileMode.Create)' Create a new stream for the compressed data.
Dim stmCompressed As Stream
If pAlgorithm = enuAlgorithm.Deflate Then
stmCompressed = New DeflateStream(stmOutFile, CompressionMode.Compress)
Else
stmCompressed = New GZipStream(stmOutFile, CompressionMode.Compress)
End If
Dim arrBuffer(4095) As Byte
Do
'Read a chunk of the input file
intReadBytes = stmInFile.Read(arrBuffer, 0, arrBuffer.Length)
'Detect the end of file
If intReadBytes = 0 Then Exit Do
'Write the compressed chunk
stmCompressed.Write(arrBuffer, 0, intReadBytes)
Loop
[/quote]
کد:
و این هم برای خارج کردن فایل از حالت فشرده
' Create a new stream for the uncompressed data.
Dim stmCompressed As Stream
If pAlgorithm = enuAlgorithm.Deflate Then
stmCompressed = New DeflateStream(stmInFile, CompressionMode.Decompress)
Else
stmCompressed = New GZipStream(stmInFile, CompressionMode.Decompress)
End If
Dim arrBuffer(4095) As Byte
Do
'Read a chunk of the input file
intReadBytes = stmCompressed.Read(arrBuffer, 0, arrBuffer.Length)
'Detect the end of file
If intReadBytes = 0 Then Exit Do
'Write the compressed chunk
stmOutFile.Write(arrBuffer, 0, intReadBytes)
Loop