Ejemplo n.º 1
0
        private void saveZippedProject(string ExtractedProjectPath, string ProjectPath)
        {
            if (ProjectPath.ToLower().EndsWith(".s7p"))
            {
                // Unpacked project - do nothing
            }
            else if (!ProjectPath.ToLower().EndsWith(".zip"))
                throw new ArgumentException("Path must be .s7p or .zip!", "Path");
            else
            {
                try
                {
                    //if (_Simatic != null)
                    //{
                    //    _Simatic.Close();
                    //    _Simatic = null;
                    //}

                    // Archive with SharpZipLib, it seems to be faster
                    File.Delete(ProjectPath);
                    ZipHelper zip = new ZipHelper("");
                    zip.ArchiveFolder(ExtractedProjectPath, ProjectPath);

                    ExtractRightProjectPath = "";
                    ExtractLeftProjectPath = "";
                }
                catch (Exception ex)
                {
                    EventFire.Error("S7.saveZippedProject. Exception: " + ex.ToString());
                }
            }
        }