Esempio n. 1
0
        private void CopyFile()
        {
            string str        = string.Format("{0}\\{1}\\", this.SourceDefaultDir, this.DirName);
            string text       = string.Format("{0}\\{1}\\", this.UserDefaultDir, this.DirName);
            string str2       = string.Format("{0}\\{1}\\", this.SourceDefaultDir, "Common\\");
            string systemPath = CommonBase.GetSystemPath();

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

            var CreoCommonPath = GetProeCommonFilesLocationPath(); //找到 "..\Creo 2.0\\Common Files\\M020" 目录

            if (string.IsNullOrEmpty(CreoCommonPath))
            {
                CreoCommonPath = GetProeCommonFilesLocationPathX64();
            }
            var xtopPath = FileAndDirectoryManager.SearchFile(CreoCommonPath, new string[] { "i486_nt\\obj", "x86e_win64\\obj" }, "xtop.exe").FirstOrDefault();

            if (string.IsNullOrEmpty(xtopPath))
            {
                throw new Exception("未找到 xtop.exe 路径。不支持绿色版,请确认正确安装!");
            }
            var pf = OSHelp.GetExcutePlatform(xtopPath);

            if (pf == Platform.X64)
            {
                CommonBase.CopyFile(str + CREOPACKAGE64, text + CREOPACKAGE);
            }
            else if (pf == Platform.X86)
            {
                CommonBase.CopyFile(str + CREOPACKAGE, text + CREOPACKAGE);
            }
            else
            {
                throw new Exception("未发现当前creo所处平台");
            }

            OpenAssistentDeal(CreoCommonPath, pf);

            if (!File.Exists("c:\\WINDOWS\\IntegrationLogin.exe"))
            {
                CommonBase.CopyFile(str2 + "IntegrationLogin.exe", "c:\\WINDOWS\\IntegrationLogin.exe");
            }
            if (!File.Exists("c:\\WINDOWS\\IntegrationLogin.exe.config"))
            {
                CommonBase.CopyFile(str2 + "IntegrationLogin.exe.config", "c:\\WINDOWS\\IntegrationLogin.exe.config");
            }

            try
            {
                string windowsPath = CommonBase.GetWindowsPath();
                CommonBase.DeleteFile(windowsPath + "\\PlmConfig.dop");//先将之前有的删除掉
            }
            catch { } //忽略错误
            //给文件、文件夹设置权限
            //system32\LoginSetting.ini
            //system32\proegm.txt
            //system32\Login.Html
            //%ALLUSERSPROFILE%\PLM\LoginSetting.ini
            //c:\windows\temp\plmpdf
            foreach (var item in DealFiles())
            {
                AccessControl.FileInfoAccessControl(item);
            }

            this.CopyMenuFile();
        }