How to Create a ZIP File Automatically Using XML

I need to find some code that will take multiple files from a given directory and create it into a zip file with a specific name using XML.

Does anyone know how i could do this or where i can go to find some info on how to accomplish it???

I already have an XML file that takes files from the same specific location and moves them to a server somewhere else.

Here is the code for that and obvioulsy if i can keep the zip file code in the similar way that would be ideal.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
UKSystemSupportAuthor Commented:
This was a very great start and it does everything i need it to do, except for that it is all done manually.

I need to try and find a way to automate this tool.

So from the link and code provided.

1.  I need to find a way to make the zip file name be saved as (Where 01012010 is today's date) So that needs to change on a daily basis.

2.  Secondly i need a way to automatically start this process as well

thanks in advance
UKSystemSupportAuthor Commented:

using System;
using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using Ionic.Zip;

namespace ZipFiles
    class Program
        static string folder_name = @"\\Scsap01\DoculinkOutput";
        static string zipName = @"Xkingsinv" + System.DateTime.Now.ToString("MM/dd/yyyy") + ".zip";

        static void Main(string[] args)
            var options = new WorkerOptions
                ZipName = folder_name + "\\" + zipName,
                Folder = folder_name,
                Encoding = "ibm437"

            _workerThread = new Thread(DoSave);
            _workerThread.Name = "Zip Saver thread";

        private static void DoSave(Object p)
            WorkerOptions options = p as WorkerOptions;
                using (var zip1 = new ZipFile())
                    zip1.ProvisionalAlternateEncoding = System.Text.Encoding.GetEncoding(options.Encoding);
                    zip1.Comment = options.Comment;
                    zip1.Password = options.Password;
                    zip1.Encryption = options.Encryption;
                    _entriesToZip = zip1.EntryFileNames.Count;                  

                    zip1.UseZip64WhenSaving = options.Zip64;
                    zip1.CompressionLevel = options.CompressionLevel;

                    if (options.ZipFlavor == 1)
                        zip1.SaveSelfExtractor(options.ZipName, SelfExtractorFlavor.WinFormsApplication);
                    else if (options.ZipFlavor == 2)
                        zip1.SaveSelfExtractor(options.ZipName, SelfExtractorFlavor.ConsoleApplication);
            catch (System.Exception exc1)
                MessageBox.Show(String.Format("Exception while zipping: {0}", exc1.Message));               

        private static Thread _workerThread;
        private static int _entriesToZip;
    public class WorkerOptions
        public string ZipName;
        public string Folder;
        public string Encoding;
        public string Comment;
        public string Password;
        public int ZipFlavor;
        public Ionic.Zlib.CompressionLevel CompressionLevel;
        public Ionic.Zip.EncryptionAlgorithm Encryption;
        public Zip64Option Zip64;


Open in new window

UKSystemSupportAuthor Commented:
code base to start from
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.