/// <summary>
        /// Opens the report.
        /// </summary>
        /// <param name="filePath"> The file path.</param>
        private void OpenReportZip(string filePath)
        {
            C1.C1Zip.C1ZipFile zipFile = new C1.C1Zip.C1ZipFile();
            zipFile.Open(filePath);

            string htmlReportFile = string.Empty;
            ArrayList htmlResponseFiles = new ArrayList();

            // do not extract icons, extract only html data into temphtml
            for (int i=0;i<zipFile.Entries.Count;i++)
            {
                C1.C1Zip.C1ZipEntry entry = zipFile.Entries[i];

                if ( i == 0 )
                {
                    htmlReportFile = Application.UserAppDataPath + "\\temphtml\\" + entry.FileName;
                    zipFile.Entries.Extract(i, htmlReportFile);
                }
                else
                {
                    if ( entry.FileName.IndexOf("htm") > -1 )
                    {
                        string destinationFilePath = Application.UserAppDataPath + "\\temphtml\\" + entry.FileName.Replace("temphtml/","");
                        zipFile.Entries.Extract(i, destinationFilePath);
                        htmlResponseFiles.Add(destinationFilePath);
                    }
                }
            }

            zipFile.Close();

            // Open report preview viewer
            LoadHtmlReportFromFile(htmlReportFile, (string[])htmlResponseFiles.ToArray(typeof(string)));
        }
        /// <summary>
        /// Saves the report as zip file.
        /// </summary>
        /// <param name="htmlReport"> The html report file path.</param>
        /// <param name="images"> The string array with images.</param>
        /// <param name="htmlFiles"> The string array with html file path.</param>
        /// <param name="fileName"> The zip file path.</param>
        private void SaveReportZip(string htmlReport,string[] images, string[] htmlFiles, string fileName)
        {
            // get file name
            string[] parts = fileName.Split('\\');
            string name = parts[parts.Length - 1];

            // check for . dots
            parts = name.Split('.');
            name = parts[0] + ".htm";

            try
            {
                C1.C1Zip.C1ZipFile zipFile = new C1.C1Zip.C1ZipFile();
                zipFile.Create(fileName);
                zipFile.Open(fileName);
                zipFile.Entries.Add(htmlReport, name);

                // resources
                foreach ( string s in images )
                {
                    if ( File.Exists(s) )
                        zipFile.Entries.Add(s);
                }

                // html files
                foreach ( string file in htmlFiles )
                {
                    if ( File.Exists(file) )
                        zipFile.Entries.Add(file,1);
                }

                zipFile.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,AppLocation.ApplicationName,MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Creates a new ScriptingApplicationPackage.
        /// </summary>
        /// <param name="application"> The scripting application.</param>
        /// <param name="arguments"> The application arguments.</param>
        /// <param name="filePath"> The output file path.</param>
        /// <param name="doEncrypt"> Sets the encrypttion setting for a scripting application.</param>
        public static void CreatePackage(ScriptingApplication application, ScriptingApplicationArgs arguments, string filePath, bool doEncrypt)
        {
            try
            {
                if ( application.Header.ApplicationID == null )
                {
                    application.Header.ApplicationID = System.Guid.NewGuid().ToString();
                }

                // Get all FileReference elements.
                FileReference[] fileReferences = application.GetFileReferences();
                string applicationPath = System.Windows.Forms.Application.UserAppDataPath;

                string temp = applicationPath + "/temp/";

                if ( !Directory.Exists(temp) )
                {
                    Directory.CreateDirectory(temp);
                }

                C1.C1Zip.C1ZipFile zipFile = new C1.C1Zip.C1ZipFile();
                zipFile.Create(filePath);
                zipFile.Open(filePath);

                string argumentsFileName = application.Header.ApplicationID + "-applicationArguments.xml";

                FileReference argumentsFileReference = new FileReference(argumentsFileName);
                application.Header.ScriptingApplicationArgumentsReference = argumentsFileReference;

                // Add Scripting Application
                string xml = string.Empty;
                if ( doEncrypt )
                {
                    xml = application.Encrypt();
                }
                else
                {
                    xml = application.ToXml();
                }

                MemoryStream mem = new MemoryStream(System.Text.Encoding.UTF8.GetByteCount(xml));
                StreamWriter writer =  new StreamWriter(mem, System.Text.Encoding.UTF8);
                writer.Write(xml);
                writer.Flush();
                mem.Position = 0;
                zipFile.Entries.Add(writer.BaseStream, application.Header.ApplicationID);
                writer.Close();

                string argsXml = "None";
                if ( arguments != null )
                {
                    // Add Scripting Application Arguments
                    argsXml = arguments.ToXml();
                }
                mem = new MemoryStream(System.Text.Encoding.UTF8.GetByteCount(argsXml));
                writer =  new StreamWriter(mem, System.Text.Encoding.UTF8);
                writer.Write(argsXml);
                writer.Flush();
                mem.Position = 0;
                zipFile.Entries.Add(writer.BaseStream, argumentsFileName);
                writer.Close();

                FileReference[] customTransforms = application.GetCustomTransforms();

                // add custom transforms
                foreach ( FileReference reference in customTransforms )
                {
                    if ( File.Exists(reference.FileName) )
                    {
                        FileInfo fileInfo = new FileInfo(reference.FileName);
                        zipFile.Entries.Add(reference.FileName, fileInfo.Name);
                    }
                }

                MemoryStream stream = new MemoryStream();
                stream.Write(new byte[] {0}, 0, 1);
                zipFile.Entries.Add(stream, "CustomTransformsSeparator");
                stream.Close();

                // add file references that are not custom transforms
                foreach ( FileReference reference in fileReferences )
                {
                    if ( File.Exists(reference.FileName) )
                    {
                        FileInfo fileInfo = new FileInfo(reference.FileName);
                        zipFile.Entries.Add(reference.FileName, fileInfo.Name);
                    }
                }

                zipFile.Close();
            }
            catch
            {
                throw;
            }
        }