private void CreateCatalogFile(string path) { CatalogTable catalog = new CatalogTable(); catalog.Items = new List <CatalogItem>(); //Far = new FAR1Archive(path, 0); DirectoryInfo dir = new DirectoryInfo(path); foreach (FileInfo file in dir.GetFiles()) { if (file.Extension == ".iff") { var iff = new IffFile(path + "/" + file.Name); ulong FileID = 0; foreach (OBJD obj in iff.List <OBJD>()) { if (obj.IsMultiTile && obj.SubIndex == -1) { FileID = obj.GUID; string name = Path.GetFileNameWithoutExtension(file.Name); catalog.Items.Add(new CatalogItem() { GUID = FileID.ToString("X"), Name = name, Category = GetCategoryName(name), Price = obj.Price }); listBox2.Items.Add(file.Name + " " + FileID); CatalogTable.Save("catalog.xml", catalog); } else if (!obj.IsMultiTile) { FileID = obj.GUID; string name = Path.GetFileNameWithoutExtension(file.Name); catalog.Items.Add(new CatalogItem() { GUID = FileID.ToString("X"), Name = name, Category = GetCategoryName(name), Price = obj.Price }); listBox2.Items.Add(file.Name + " " + FileID); CatalogTable.Save("catalog.xml", catalog); } } } } }
public static void Save(string xmlFilePath, CatalogTable table) { XmlSerializer serialize = new XmlSerializer(typeof(CatalogTable)); using (var writer = new StreamWriter(xmlFilePath)) { serialize.Serialize(writer, table); } }