Private Function Compress(ByVal fileToCompress As FileInfo) As Boolean
Dim _Compress As Boolean
Using originalFileStream As FileStream = fileToCompress.OpenRead()
If (File.GetAttributes(fileToCompress.FullName) And FileAttributes.Hidden) <> FileAttributes.Hidden And fileToCompress.Extension <> ".gz" Then
Using compressedFileStream As FileStream = File.Create(fileToCompress.FullName + ".gz")
Using compressionStream As GZipStream = New GZipStream(compressedFileStream, CompressionMode.Compress)
originalFileStream.CopyTo(compressionStream)
Console.WriteLine("Compressed {0} from {1} to {2} bytes.",
fileToCompress.Name, fileToCompress.Length.ToString(), compressedFileStream.Length.ToString())
End Using
End Using
End If
End Using
_Compress = File.Exists(fileToCompress.FullName + ".gz")
Return _Compress
End Function
Willkommen bei Stack Overflow. Bitte lesen Sie den folgenden Artikel darüber, wie Sie eine Frage auf dieser Website stellen können: http://stackoverflow.com/help/how-to-ask –