Пример #1
0
        public bool Extract(out DynamoInstalledPackage pkg)
        {
            if (this.DownloadState != State.Downloaded)
            {
                throw new Exception("The package cannot be extracted unless it is downloaded. ");
            }

            this.DownloadState = State.Installing;

            // unzip, place files
            var unzipPath = Greg.Utility.FileUtilities.UnZip(DownloadPath);

            if (!Directory.Exists(unzipPath))
            {
                throw new Exception("The package was found to be empty and was not installed.");
            }

            var installedPath = BuildInstallDirectoryString();

            Directory.CreateDirectory(installedPath);

            // Now create all of the directories
            foreach (string dirPath in Directory.GetDirectories(unzipPath, "*", SearchOption.AllDirectories))
            {
                Directory.CreateDirectory(dirPath.Replace(unzipPath, installedPath));
            }

            // Copy all the files
            foreach (string newPath in Directory.GetFiles(unzipPath, "*.*", SearchOption.AllDirectories))
            {
                File.Copy(newPath, newPath.Replace(unzipPath, installedPath));
            }

            // provide handle to installed package
            pkg = new DynamoInstalledPackage(installedPath, Header.name, VersionName);

            return(true);
        }
Пример #2
0
        public bool Extract( out DynamoInstalledPackage pkg )
        {
            if (this.DownloadState != State.Downloaded)
            {
                throw new Exception("The package cannot be extracted unless it is downloaded. ");
            }

            this.DownloadState = State.Installing;

            // unzip, place files
            var unzipPath = Greg.Utility.FileUtilities.UnZip(DownloadPath);
            if (!Directory.Exists(unzipPath))
            {
                throw new Exception("The package was found to be empty and was not installed.");
            }

            var installedPath = BuildInstallDirectoryString();
            Directory.CreateDirectory(installedPath);

            // Now create all of the directories
            foreach (string dirPath in Directory.GetDirectories(unzipPath, "*", SearchOption.AllDirectories))
                Directory.CreateDirectory(dirPath.Replace(unzipPath, installedPath));

            // Copy all the files
            foreach (string newPath in Directory.GetFiles(unzipPath, "*.*", SearchOption.AllDirectories))
                File.Copy(newPath, newPath.Replace(unzipPath, installedPath));

            // provide handle to installed package
            pkg = new DynamoInstalledPackage(installedPath, Header.name, VersionName);

            return true;
        }