Torna al Thread

Public Function SaveFileHasZip(ByRef _listOfFile As List(Of String), ByVal _dstFilePathWithName As String) As Boolean ' Il file di destinazione Dim zipStream As ZipOutputStream = New ZipOutputStream(IO.File.Create(_dstFilePathWithName)) ' Scorre i file da comprimere e li inserisce nel file Dim kSpace As Integer For kSpace = 0 To _listOfFile.Count - 1 Dim fs As IO.FileStream = IO.File.OpenRead(_listOfFile(kSpace)) Dim buffer() As Byte = Array.CreateInstance(GetType(Byte), fs.Length) fs.Read(buffer, 0, buffer.Length) 'Crea una nuova entry nel file ZIP. Dim entry As ZipEntry = New ZipEntry(IO.Path.GetFileName(_listOfFile(kSpace))) fs.Close() zipStream.PutNextEntry(entry) zipStream.Write(buffer, 0, buffer.Length) buffer = Nothing fs.Close() : fs.Dispose() : fs = Nothing Next ' chiude il compressore. zipStream.Finish() zipStream.Close() zipStream.Dispose() Return True End Function
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5