Ließt den base64 codierten Anteil aus der XML Datei aus und speichert diesen decodiert als Datei ab
/// <summary>
/// Read a XML file including a binary file and create the binary file.
/// </summary>
/// <param name="pathBinary"></param>
/// <param name="pathXML"></param>
private void XMLToBinary(string pathBinary, string pathXML)
{
int readBytes = 0;
byte[] buffer = new byte[1000];
FileStream fileStream = new FileStream(pathBinary, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write);
BinaryWriter binaryWriter = new BinaryWriter(fileStream);
XmlReader xmlReader = XmlReader.Create(pathXML);
xmlReader.ReadToFollowing("BinaryFile");
while ((readBytes = xmlReader.ReadElementContentAsBase64(buffer, 0, 50)) > 0)
{
binaryWriter.Write(buffer, 0, readBytes);
}
fileStream.Close();
xmlReader.Close();
}
Kommentare zum Snippet