示例#1
0
 private static void ListContent(string filename)
 {
     CompoundFileSystem compoundFile = new CompoundFileSystem(filename);
     Console.WriteLine("Content of '{0}': ", filename);
     Console.WriteLine();
     Console.WriteLine("Type\tModified\tLength\tName");
     int i = 0;
     foreach (KeyValuePair<string, CompoundFileStorage> pair in
         ListStorage(compoundFile.GetRootStorage(), "/"))
     {
         Console.WriteLine("{0}\t{1}\t{2}\t\"{3}\"",
             pair.Value.ObjectType, pair.Value.Modified, pair.Value.Length, pair.Key);
         ++i;
     }
     Console.WriteLine("{0} item(s) found", i);
 }
示例#2
0
 private static void ExtractContext(string filename, string itemName, string target)
 {
     Console.WriteLine("Extracting stream \'{1}\' from of '{0}'", filename, itemName);
     CompoundFileSystem compoundFile = new CompoundFileSystem(filename);
     CompoundFileStorage storage = null;
     foreach (KeyValuePair<string, CompoundFileStorage> pair in
         ListStorage(compoundFile.GetRootStorage(), "/"))
     {
         if (pair.Key == itemName) storage = pair.Value;
     }
     if (storage != null)
     {
         storage.CopyToFile(target);
         Console.WriteLine("The {0} bytes were saved to '{1}'", storage.Length, target);
     }
     else
         Console.WriteLine("The stream was not found");
 }
示例#3
0
        public void Load(CompoundFileSystem system)
        {
            const string WordDocumentStreamName = "WordDocument";
            CompoundFileStorage wordDocumentStorage = system.GetRootStorage().FindStorage(WordDocumentStreamName);
            wordDocumentStorage.CopyToFile("wd.bin");
            using (Stream wordDocumentStream = wordDocumentStorage.CreateStream())
            {
                Fib fib;
                fib = FibStructuresReader.ReadFib(wordDocumentStream);

                string tableStreamName = GetTableStreamName(fib);
                CompoundFileStorage tableStorage = system.GetRootStorage().FindStorage(tableStreamName);
                tableStorage.CopyToFile(tableStreamName + ".bin");
                using (Stream tableStream = tableStorage.CreateStream())
                {
                    LoadContent(wordDocumentStream, tableStream, fib);
                }
            }
        }