예제 #1
0
        private void DumpStorage(StorageInfo storageInfo, string storageName, XmlWriter writer)
        {
            writer.WriteStartElement("storage");
            writer.WriteAttributeString("name", storageName);

            StorageInfo[] subStorages = storageInfo.GetSubStorages();
            foreach (StorageInfo subStorage in subStorages)
            {
                DumpStorage(subStorage, subStorage.Name, writer);
            }

            StreamInfo[] streams = storageInfo.GetStreams();
            foreach (StreamInfo stream in streams)
            {
                string hexData = ConvertStreamBytesToHex(stream);
                writer.WriteStartElement("stream");
                using (var rawStream = new BinaryReader(stream.GetStream(FileMode.Open, FileAccess.Read)))
                {
                    var streamsBase = Path.Combine(BasePath, Path.GetFileName(_oleStorageFilePath.FullPathString) + "_streams");
                    FileSystem.CreateDirectory(streamsBase);
                    File.WriteAllBytes(Path.Combine(streamsBase, stream.Name).FullPathString, rawStream.ReadBytes((int)rawStream.BaseStream.Length));
                    writer.WriteAttributeString("name", stream.Name);
                    writer.WriteAttributeString("data", hexData);
                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement();
        }