Esempio n. 1
0
        public int ZipFiles()
        {
            //check to see if there is enough information to proceed.
            //Exceptions can be thrown if required data is not passed in
            if (m_FilesToZip.Length == 0)
            {
                return(-1);
            }
            if (m_ZipFileName == string.Empty)
            {
                return(-1);
            }

            m_zuf = new ZIPUSERFUNCTIONS();

            //set up the callback delegates
            m_CallbackPrint    = new ZDLLPrintCallback(ZDLLPrint);
            m_CallbackService  = new ZDLLServiceCallback(ZDLLService);
            m_CallbackPassword = new ZDLLPasswordCallback(ZDLLPassword);
            m_CallbackComment  = new ZDLLCommentCallback(ZDLLComment);

            //set up the callback structure
            m_zuf.ZDLLPRNT     = m_CallbackPrint;
            m_zuf.ZDLLSERVICE  = m_CallbackService;
            m_zuf.ZDLLPASSWORD = m_CallbackPassword;
            m_zuf.ZDLLCOMMENT  = m_CallbackComment;

            //init the zip process
            int ret = ZpInit(ref m_zuf);

            //set the zip options
            ZPOPT zopt = CreateZPOPTOptions();

            ret = ZpSetOptions(ref zopt);

            //zip the files
            try
            {
                ret = ZpArchive(m_FilesToZip.Length, m_ZipFileName, m_FilesToZip);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString() + "\r\n" + "Last Win32ErrorCode: " + Marshal.GetLastWin32Error());
                //You can check the meaning of return codes here:
                //http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes__0-499_.asp
            }
            return(ret);
        }
Esempio n. 2
0
        public int ZipFiles()
        {
            //check to see if there is enough information to proceed.
            //Exceptions can be thrown if required data is not passed in
            if (m_FilesToZip.Length == 0) return -1;
            if (m_ZipFileName == string.Empty) return -1;

            m_zuf = new ZIPUSERFUNCTIONS();

            //set up the callback delegates
            m_CallbackPrint = new ZDLLPrintCallback(ZDLLPrint);
            m_CallbackService = new ZDLLServiceCallback(ZDLLService);
            m_CallbackPassword = new ZDLLPasswordCallback(ZDLLPassword);
            m_CallbackComment = new ZDLLCommentCallback(ZDLLComment);

            //set up the callback structure
            m_zuf.ZDLLPRNT = m_CallbackPrint;
            m_zuf.ZDLLSERVICE = m_CallbackService;
            m_zuf.ZDLLPASSWORD = m_CallbackPassword;
            m_zuf.ZDLLCOMMENT = m_CallbackComment;

            //init the zip process
            int ret = ZpInit(ref m_zuf);

            //set the zip options
            ZPOPT zopt = CreateZPOPTOptions();
            ret = ZpSetOptions(ref zopt);

            //zip the files
            try
            {
                ret = ZpArchive(m_FilesToZip.Length, m_ZipFileName, m_FilesToZip);
            }
            catch(Exception e)
            {
                MessageBox.Show (e.ToString() + "\r\n" + "Last Win32ErrorCode: " + Marshal.GetLastWin32Error());
                //You can check the meaning of return codes here:
                //http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes__0-499_.asp
            }
            return ret;
        }