cancel
Showing results for 
Search instead for 
Did you mean: 

Creating/Moving files to a ZIP Folder

Anonymous
Not applicable
I am able to create a ZIP Folder using the Write Text File action from Utilities - File Management and giving the file extension ".zip" but once created I can not find a way to move or copy existing files into it. Anyone have a code solution to this? Cheers
12 REPLIES 12

John__Carter
Staff
Staff
That won't work, the file you've created is not a zip file, it's a text file with a different extension. You need an app like WinZip or 7zip to create a zip file - both these apps have a command line interface that you can execute using the Utility - Environment object.

MarioG
Level 2
It is very easy to create Zip files, if you add a custom code stage, whit these 3 lines of code you can generate zip files from a folder path Dim startPath As String = dirToZip Dim zipPath As String = zipFileName ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest, False) I hope it helps

Anonymous
Not applicable
Thanks for the reply and the code. I have pasted your code directly into a code stage and given it the two text inputs ""dirToZip"" and ""zipFileName"". I am however getting errors when I Check Code: ""Compile error at line 3: 'ZipFile' is not declared. It may be inaccessible due to its protection level."" ""Compile error at line 3: 'CompressionLevel' is not declared. It may be inaccessible due to its protection level."" Where am I going wrong?

Perhaps you need to import certain Dll's or namespaces? @marioagv?

Anonymous
Not applicable
I've fixed the issue myself my including the Namespaces System.IO.Compression and System.IO.Compression.FileZip.dll

Anonymous
Not applicable
I've fixed the issue myself by including the Namespaces System.IO.Compression and System.IO.Compression.FileZip.dll

UshaRani1
Level 2
Hi Team, I have spyed the ""ol"" element in webpage and stored all ""li"" elements into one collection, here the collection contains only one column with header ""Item Text"". Please suggest me how can I get each ""li"" item value in each loop iteration. I tried like collectionname.Column1, it is not working.

EdBonk
Level 2
The solution previously provided works in instances where you want to zip all the contents of a particular directory. If you want to zip select files from a directory you could do the following: In below example following are inputs to a code stage Source_Files_Directory (Text - Path to directory containing files to be zipped) Source_Files_Collection (Collection - Single text column called ""Source_File"" to store list of files to be zipped) Zip_Archive_Directory (Text - Path to directory where zip file will be created) Zip_Archive_Name (Text - Name of zip file) In addition to the external references already noted this requires the following to use FileStream for creating the empty zip archive file: System.IO.Compression.FileSystem.dll 'Create empty zip archive Dim FileStream as FileStream = new FileStream(Zip_Archive_Directory & Zip_Archive_Name, FileMode.Create) FileStream.Close() 'Add files to zip archive Using archive As ZipArchive = ZipFile.Open(Zip_Archive_Directory & Zip_Archive_Name, ZipArchiveMode.Update) For Each r as System.Data.DataRow In Source_Files_Collection.Rows If System.IO.File.Exists(Source_Files_Directory & CStr(r(""Source_File""))) Then Archive.CreateEntryFromFile(Source_Files_Directory & CStr(r(""Source_File"")), CStr(r(""Source_File"")), CompressionLevel.Fastest) End If Next End Using

RaivisLazdāns
Level 4
Hi, Is it somehow possible to retrieve file names when ZIP is extracted? Thanks in advance!