private ResourceEntry WriteFlashEntry(ResourceEntry entry, XPathNodeIterator nodes, string sdsFolder, XmlNode descNode) { FlashResource resource = new FlashResource(); //read contents from XML entry nodes.Current.MoveToNext(); resource.FileName = nodes.Current.Value; nodes.Current.MoveToNext(); resource.Name = nodes.Current.Value; nodes.Current.MoveToNext(); entry.Version = (ushort)nodes.Current.ValueAsInt; resource.Data = File.ReadAllBytes(sdsFolder + "/" + resource.FileName); using (var stream = new MemoryStream()) { resource.Serialize(entry.Version, stream, _Endian); entry.Data = stream.ToArray(); } descNode.InnerText = resource.FileName; return(entry); }
private string ReadFlashEntry(ResourceEntry entry, XmlWriter resourceXML, string name, string flashDir) { // Read the resource first; we have the nicety of having the flash name stored // in the meta info. FlashResource resource = new FlashResource(); using (var stream = new MemoryStream(entry.Data)) { resource.Deserialize(entry.Version, stream, Endian); entry.Data = resource.Data; } // Since we know that flash will have the filename, // we collect it from here instead. if (string.IsNullOrEmpty(name)) { name = resource.FileName; } string[] dirs = name.Split('/'); string newPath = flashDir; for (int z = 0; z != dirs.Length - 1; z++) { newPath += "/" + dirs[z]; Directory.CreateDirectory(newPath); } newPath += "/" + dirs[dirs.Length - 1]; resourceXML.WriteElementString("File", name); resourceXML.WriteElementString("Name", resource.Name); // In this case this is valid; we will no doubt get a name. return(name); }