I open a wave bank file, reading the xml file connected with the bank file
Sample XML
<?xml version="1.0" encoding="iso-8859-1"?>
<wavebank name="menu_music_wave" dir="data/sound/music/menu_music/" size_before="18639744" size="27268046" compression="28 %" xmlns:xi="x">
<wave name="menu_music01" file="menu_music01.wav" stream="true" file_priority="low" quality="44100 adpcm" size_before="36286068" size="10205544" compression="28 %" bank="menu_music_wave.bank" offset="0"/>
<wave name="outro_music01" file="outro_music01.wav" stream="true" file_priority="low" quality="44100 adpcm" size_before="29990778" size="8434200" compression="28 %" bank="menu_music_wave.bank" offset="10205544"/>
<wave name="menu_music02" file="menu_music02.wav" stream="true" file_priority="low" quality="44100 adpcm" size_before="36286068" size="10205544" compression="28 %" bank="menu_music_wave.bank" offset="18639744"/>
</wavebank>
Here is the code I use to read the xml
if (this.openFileDialog1.ShowDialog() != DialogResult.OK)
{
return;
}
string fileName = this.openFileDialog1.FileName;
this.listView1.Items.Clear();
Directory.SetCurrentDirectory(Path.GetDirectoryName(fileName));
FileStream fileStream = null;
try
{
fileStream = File.Open(fileName, FileMode.Open);
XmlTextReader xmlTextReader = new XmlTextReader(fileStream);
while (xmlTextReader.Read())
{
if (xmlTextReader.Name == "wave" && xmlTextReader.NodeType == XmlNodeType.Element)
{
Hashtable hashtable = new Hashtable();
_ = xmlTextReader.Name;
if (xmlTextReader.HasAttributes)
{
for (int i = 0; i < xmlTextReader.AttributeCount; ++i)
{
xmlTextReader.MoveToAttribute(i);
hashtable.Add(xmlTextReader.Name, xmlTextReader.Value);
}
}
this.listView1.Items.Add(new ListViewItem()
{
Text = hashtable["file"].ToString(),
SubItems = { hashtable["size"].ToString(), hashtable["bank"].ToString(), hashtable["offset"].ToString() },
Tag = hashtable
});
}
}
}
finally
{
fileStream?.Close();
}
Now I want to save the *,bank file