Пример #1
0
        /// <summary>
        ///     Checks if a child storage exists within the parent.
        /// </summary>
        /// <param name="storageName">Name of the storage to look for.</param>
        /// <returns>A boolean value indicating whether the child storage was found.</returns>
        public bool ExistsStorage(string storageName)
        {
            CheckDisposed();

            var cfMock = new CFMock(storageName, StgType.StgStorage);

            CFItem directoryEntry;

            return(Children.TryFind(cfMock, out directoryEntry) && directoryEntry.DirEntry.StgType == StgType.StgStorage);
        }
Пример #2
0
        /// <summary>
        ///     Checks whether a child stream exists in the parent.
        /// </summary>
        /// <param name="streamName">Name of the stream to look for</param>
        /// <returns>A boolean value indicating whether the child stream exists.</returns>
        /// <example>
        ///     <code>
        ///  string filename = "report.xls";
        ///
        ///  CompoundFile cf = new CompoundFile(filename);
        ///
        ///  bool exists = ExistsStream("Workbook");
        ///
        ///  if exists
        ///  {
        ///      CFStream foundStream = cf.RootStorage.GetStream("Workbook");
        ///
        ///      byte[] temp = foundStream.GetData();
        ///  }
        ///
        ///  Assert.IsNotNull(temp);
        ///
        ///  cf.Close();
        ///  </code>
        /// </example>
        public bool ExistsStream(string streamName)
        {
            CheckDisposed();

            var tmp = new CFMock(streamName, StgType.StgStream);

            CFItem outDe;

            return(Children.TryFind(tmp, out outDe) && outDe.DirEntry.StgType == StgType.StgStream);
        }
Пример #3
0
        /// <summary>
        ///     Get a named
        ///     <see cref="T:DocumentServices.Modules.Extractors.OfficeExtractor.OLECompoundFileStorage.CFStream">stream</see>
        ///     contained in the current storage if existing.
        /// </summary>
        /// <param name="streamName">Name of the stream to look for</param>
        /// <returns>A stream reference if existing</returns>
        /// <exception cref="CFItemNotFound">Raised if <see cref="streamName" /> is not found</exception>
        public ICFStream GetStream(string streamName)
        {
            CheckDisposed();

            var cfMock = new CFMock(streamName, StgType.StgStream);

            CFItem directoryEntry;

            if (Children.TryFind(cfMock, out directoryEntry) && directoryEntry.DirEntry.StgType == StgType.StgStream)
            {
                return(directoryEntry as CFStream);
            }

            throw new CFItemNotFound("Cannot find item [" + streamName + "] within the current storage");
        }