Exemple #1
0
        public GameXmlFiles() {
            if (!DataFolder.Exists)
                DataFolder.Create();



            DirectorySecurity dSecurity = DataFolder.GetAccessControl();
            dSecurity.AddAccessRule(new FileSystemAccessRule("everyone", 
                FileSystemRights.FullControl, 
                InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow));
            DataFolder.SetAccessControl(dSecurity);
            prepareDataFiles();


            List<FileInfo> files = new List<FileInfo>();
            foreach (FileInfo info in DataFolder.GetFiles("*.xml")) {
                if (ReadableXmlFiles.Contains(info.Name))
                    files.Add(info);
            }

            try {
                this.LoadXml(files);
                if (this.custom == null)
                    this.custom = new CustomGameXmlFile(new FileInfo(Path.Combine(DataFolder.FullName, "custom.xml")));
            } catch (DirectoryNotFoundException e) {
                throw new TranslateableException("CouldNotFindGameProfilesFolder", e);
            } catch (FileNotFoundException e) {
                throw new TranslateableException("NoXmlFilesInDataFolder", e);
            }

            if (this.custom == null) {
                this.custom = new CustomGameXmlFile(new FileInfo(Path.Combine(DataFolder.FullName, "custom.xml")));
            }
        }