
''' Compress a given folder splitting the zip files based on a supplied maximum uncompressed file length. To use the code to compress your desktop to a folder in your "My Documents" folder using a byte threshold of 50MB you'd just do something like: Dim FolderToCompress = Environment.GetFolderPath()ĭim FolderToSaveZipTo = Path.Combine(Environment.GetFolderPath(), "ZIPs")ĬompressFolder(FolderToCompress, FolderToSaveZipTo, "MyArchive", 1024 * 1024 * 50) There are two methods, one takes an optional array of file extensions that you don't want to compress. The code's comments should hopefully explain everything. However, based on your requirements this should be a problem. The only downside of this code is that the maximum byte threshold is calculated based on the uncompressed file length because the compressed size isn't known until later. It walks a given folder, adds files to a zip file, and creates new zip files once a maximum byte threshold is reached. Net 4.5 and you need to add a reference to both System.IO.Compression and System.IO.Compression.FileSystem in your project. Net runtime actually has compression built into it and recent versions have made it even easier to us to use.įor the code below to work you need to have. Would you be open to a different solution that doesn't use WinZip at all? The. " & numberOfErrors.ToString & " error(s) encountered" LblCountItemsDone.Text = processedNumberCount.ToStringĭim title As String = "TIFF Files Zip Completed"ĭim msg As String = "Process Complete, " & processedNumberCount & " files processed successfully. ProcessedNumberCount = processedNumberCount + 1 PsiProcess.WindowStyle = ProcessWindowStyle.Minimized PsiProcess.WorkingDirectory = newFolderURL PsiProcess.FileName = "C:\Program Files\Winzip\wzzip.exe" ReNamedTo = newFolderURL & "\" & folderName & ".zip" 'must download winZip command line 32 / 64 bit depending on the verion of winZip u haveĭim dirInfo As New System.IO.DirectoryInfo(newFolderURL)ĭim folderName As String = (dirInfo.Name) NewFolderURL = ListBoxFoldersToBeDone.Items(i).ToString Here is my code Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Clickĭim folderInfo As New ()įor i = 0 To - 1 I would like to split the file when it gets to 2GB. I have very large Tiffs files which are more than 100MB.

I currently have a commandline which works fine but crushes if the folder is more than 4GB.
