示例#1
0
        private void DeleteUnnecessaryFile()
        {
            ChosenPlatforms chosenPlats;

            try
            {
                string          binFilePath = Application.dataPath + "/ShareSDKiOSAutoPackage/Editor/SDKPorter/ManagePlatforms/ChosenPlatforms.bin";
                BinaryFormatter formatter   = new BinaryFormatter();
                Stream          destream    = new FileStream(binFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                chosenPlats = (ChosenPlatforms)formatter.Deserialize(destream);
                destream.Flush();
                destream.Close();
            }
            catch (Exception)
            {
                chosenPlats = new ChosenPlatforms();
            }

            Type t = chosenPlats.GetType();

            foreach (PropertyInfo platform in t.GetProperties())
            {
                Hashtable plat = (Hashtable)platform.GetValue(chosenPlats, null);

                if (!(Boolean)plat["chosen"])
                {
                    //删除多余平台相关文件
                    if (plat ["sdkPath"] != null)
                    {
                        DirectoryInfo di = new DirectoryInfo(this.projectRootPath + (string)plat ["sdkPath"]);
                        if (di.Exists)
                        {
                            di.Delete(true);
                        }
                    }

                    if (plat ["connectorPath"] != null)
                    {
                        DirectoryInfo di = new DirectoryInfo(this.projectRootPath + (string)plat ["connectorPath"]);
                        if (di.Exists)
                        {
                            di.Delete(true);
                        }
                    }

                    if (plat ["jsPath"] != null)
                    {
                        if (File.Exists(this.projectRootPath + (string)plat ["jsPath"]))
                        {
                            File.Delete(this.projectRootPath + (string)plat ["jsPath"]);
                        }
                    }
                }
            }
        }
        private void Prepare()
        {
            string filePath = Application.dataPath + "/ShareSDKiOSAutoPackage/Editor/SDKPorter/ManagePlatforms/ChosenPlatforms.bin";

            try
            {
                BinaryFormatter formatter   = new BinaryFormatter();
                Stream          destream    = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                ChosenPlatforms chosenPlats = (ChosenPlatforms)formatter.Deserialize(destream);
                destream.Flush();
                destream.Close();
                this.chosenPlats = chosenPlats;
            }
            catch (Exception)
            {
                this.chosenPlats = new ChosenPlatforms();
            }
        }