AsposeVisualStudioPluginCells.GUI.SampleWizardPage.CopyAndCreateProject C# (CSharp) Method

CopyAndCreateProject() private method

private CopyAndCreateProject ( ) : bool
return bool
        bool CopyAndCreateProject()
        {
            progressBar1.Visible = true;
            progressBar1.Value = 10;
            toolStripStatusMessage.Visible = true;
            toolStripStatusMessage.Text = "Fetching Examples: - Please wait while we configure you preferences";
            AsposeComponent component;
            AsposeComponents.list.TryGetValue(Constants.ASPOSE_COMPONENT, out component);
            //TreeNodeData nodeData = (TreeNodeData)selectedNode.Tag;
            string sampleSourcePath = "Examples";
            string repoPath = GitHelper.getLocalRepositoryPath(component);
            string destinationPath = GetDestinationPath(textBoxLocation.Text + "\\" + Constants.ASPOSE_COMPONENT, sampleSourcePath);
            progressBar1.Value = 30;

            bool isSuccessfull = false;
            try
            {
                CopyFolderContents(Path.Combine(repoPath, sampleSourcePath), destinationPath);
                progressBar1.Value = 40;

                string dllsRootPath = AsposeComponentsManager.getLibaryDownloadPath();
                string[] dllsPaths = Directory.GetFiles(Path.Combine(dllsRootPath, component.Name + "/lib/net40/"), "*.dll");
                for (int i = 0; i < dllsPaths.Length; i++)
                {
                    if (!Directory.Exists(Path.Combine(destinationPath, "Bin")))
                        Directory.CreateDirectory(Path.Combine(destinationPath, "Bin"));
                    File.Copy(dllsPaths[i], Path.Combine(destinationPath, "Bin", Path.GetFileName(dllsPaths[i])), true);
                }

                progressBar1.Value = 50;

                string[] projectFiles = Directory.GetFiles(Path.Combine(destinationPath, (rdbCSharp.Checked ? "CSharp" : "VisualBasic")), (rdbCSharp.Checked ? "*.csproj" : "*.vbproj"));
                for (int i = 0; i < projectFiles.Length; i++)
                {
                    UpdatePrjReferenceHintPath(projectFiles[i], component);
                }
                progressBar1.Value = 70;

                int vsVersion = GetVSVersion();

                if (vsVersion >= 2010) vsVersion = 2010; // Since our examples mostly have 2010 solution files

                string[] solutionFiles = Directory.GetFiles(Path.Combine(destinationPath, (rdbCSharp.Checked ? "CSharp" : "VisualBasic")), (rdbCSharp.Checked ? "*.sln" : "*.sln"));
                progressBar1.Value = 80;

                try
                {
                    if (solutionFiles.Length > 0)
                    {
                        foreach (string sFile in solutionFiles)
                        {
                            if (sFile.Contains(vsVersion.ToString()))
                            {
                                _application.Solution.Open(sFile);
                                isSuccessfull = true;
                                break;
                            }
                        }

                        if (!isSuccessfull)
                        {
                            System.Diagnostics.Process.Start(solutionFiles[solutionFiles.Count() - 1]);
                            isSuccessfull = true;
                        }
                    }
                    else if (projectFiles.Length > 0)
                    {
                        System.Diagnostics.Process.Start(projectFiles[0]);
                        isSuccessfull = true;
                    }
                    progressBar1.Value = 90;

                }
                catch (Exception)
                {
                    if (solutionFiles.Length > 0)
                    {
                        System.Diagnostics.Process.Start(solutionFiles[0]);
                        isSuccessfull = true;
                    }
                    else if (projectFiles.Length > 0)
                    {
                        System.Diagnostics.Process.Start(projectFiles[0]);
                        isSuccessfull = true;
                    }
                    progressBar1.Value = 90;

                }
            }
            catch (Exception)
            { }

            if (!isSuccessfull)
            {
                MessageBox.Show("Oops! We are unable to open the example project. Please open it manually from " + destinationPath);
                return false;
            }
            progressBar1.Value = 100;

            return true;
        }