当前位置: 首页>>代码示例>>C#>>正文


C# FileSystem.DirectoryNode类代码示例

本文整理汇总了C#中NPOI.POIFS.FileSystem.DirectoryNode的典型用法代码示例。如果您正苦于以下问题:C# DirectoryNode类的具体用法?C# DirectoryNode怎么用?C# DirectoryNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DirectoryNode类属于NPOI.POIFS.FileSystem命名空间,在下文中一共展示了DirectoryNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestConstructor

        public void TestConstructor()
        {
            DirectoryProperty property1 = new DirectoryProperty("directory");
            RawDataBlock[] rawBlocks = new RawDataBlock[4];
            MemoryStream stream =
                new MemoryStream(new byte[2048]);

            for (int j = 0; j < 4; j++)
            {
                rawBlocks[j] = new RawDataBlock(stream);
            }
            POIFSDocument document = new POIFSDocument("document", rawBlocks,
                                             2000);
            DocumentProperty property2 = document.DocumentProperty;
            DirectoryNode parent = new DirectoryNode(property1, (POIFSFileSystem)null, null);
            DocumentNode node = new DocumentNode(property2, parent);

            // Verify we can retrieve the document
            Assert.AreEqual(property2.Document, node.Document);

            // Verify we can Get the size
            Assert.AreEqual(property2.Size, node.Size);

            // Verify isDocumentEntry returns true
            Assert.IsTrue(node.IsDocumentEntry);

            // Verify isDirectoryEntry returns false
            Assert.IsTrue(!node.IsDirectoryEntry);

            // Verify GetName behaves correctly
            Assert.AreEqual(property2.Name, node.Name);

            // Verify GetParent behaves correctly
            Assert.AreEqual(parent, node.Parent);
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:35,代码来源:TestDocumentNode.cs

示例2: EncryptionInfo

        public EncryptionInfo(DirectoryNode dir)
        {
            DocumentInputStream dis = dir.CreateDocumentInputStream("EncryptionInfo");
            versionMajor = dis.ReadShort();
            versionMinor = dis.ReadShort();

            encryptionFlags = dis.ReadInt();

            if (versionMajor == 4 && versionMinor == 4 && encryptionFlags == 0x40)
            {
                StringBuilder builder = new StringBuilder();
                byte[] xmlDescriptor = new byte[dis.Available()];
                dis.Read(xmlDescriptor);
                foreach (byte b in xmlDescriptor)
                    builder.Append((char)b);
                string descriptor = builder.ToString();
                header = new EncryptionHeader(descriptor);
                verifier = new EncryptionVerifier(descriptor);
            }
            else
            {
                int hSize = dis.ReadInt();
                header = new EncryptionHeader(dis);
                if (header.Algorithm == EncryptionHeader.ALGORITHM_RC4)
                {
                    verifier = new EncryptionVerifier(dis, 20);
                }
                else
                {
                    verifier = new EncryptionVerifier(dis, 32);
                }
            }
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:33,代码来源:EncryptionInfo.cs

示例3: DisplayDirectory

        public static void DisplayDirectory(DirectoryNode dir, String indent)
        {
            Console.WriteLine(indent + dir.Name + " -");
            String newIndent = indent + "  ";

            IEnumerator it = dir.Entries;
            while (it.MoveNext())
            {
                Object entry = it.Current;
                if (entry is DirectoryNode)
                {
                    DisplayDirectory((DirectoryNode)entry, newIndent);
                }
                else
                {
                    DocumentNode doc = (DocumentNode)entry;
                    String name = doc.Name;
                    if (name[0] < 10)
                    {
                        String altname = "(0x0" + (int)name[0] + ")" + name.Substring(1);
                        name = name.Substring(1) + " <" + altname + ">";
                    }
                    Console.WriteLine(newIndent + name);
                }
            }
        }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:26,代码来源:POIFSLister.cs

示例4: CreateFromEmbeddedOleObject

        /// <summary>
        /// Creates an instance of this class from an embedded OLE Object. The OLE Object is expected
        /// to include a stream &quot;{01}Ole10Native&quot; which contains the actual
        /// data relevant for this class.
        /// </summary>
        /// <param name="directory">directory POI Filesystem object</param>
        /// <returns>Returns an instance of this class</returns>
        public static Ole10Native CreateFromEmbeddedOleObject(DirectoryNode directory)
        {
            DocumentEntry nativeEntry =
               (DocumentEntry)directory.GetEntry(OLE10_NATIVE);
            byte[] data = new byte[nativeEntry.Size];
            directory.CreateDocumentInputStream(nativeEntry).Read(data);

            return new Ole10Native(data, 0);
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:16,代码来源:Ole10Native.cs

示例5: DirectoryTreeNode

        public DirectoryTreeNode(DirectoryNode dn)
            : base(dn)
        {
            this.DirectoryNode = dn;

            ChangeImage("Folder");

            this.Nodes.Add(string.Empty); // Dummy node
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:9,代码来源:DirectoryTreeNode.cs

示例6: TestEmptyConstructor

        public void TestEmptyConstructor()
        {
            POIFSFileSystem fs = new POIFSFileSystem();
            DirectoryProperty property1 = new DirectoryProperty("parent");
            DirectoryProperty property2 = new DirectoryProperty("child");
            DirectoryNode parent = new DirectoryNode(property1, fs, null);
            DirectoryNode node = new DirectoryNode(property2, fs, parent);

            Assert.AreEqual(0, parent.Path.Length);
            Assert.AreEqual(1, node.Path.Length);
            Assert.AreEqual("child", node.Path.GetComponent(0));

            // Verify that GetEntries behaves correctly
            int count = 0;
            IEnumerator iter = node.Entries;

            while (iter.MoveNext())
            {
                count++;
            }
            Assert.AreEqual(0, count);

            // Verify behavior of IsEmpty
            Assert.IsTrue(node.IsEmpty);

            // Verify behavior of EntryCount
            Assert.AreEqual(0, node.EntryCount);

            // Verify behavior of Entry
            try
            {
                node.GetEntry("foo");
                Assert.Fail("Should have caught FileNotFoundException");
            }
            catch (FileNotFoundException )
            {

                // as expected
            }

            // Verify behavior of isDirectoryEntry
            Assert.IsTrue(node.IsDirectoryEntry);

            // Verify behavior of GetName
            Assert.AreEqual(property2.Name, node.Name);

            // Verify behavior of isDocumentEntry
            Assert.IsTrue(!node.IsDocumentEntry);

            // Verify behavior of GetParent
            Assert.AreEqual(parent, node.Parent);
        }
开发者ID:89sos98,项目名称:npoi,代码行数:52,代码来源:TestDirectoryNode.cs

示例7: GetChildren

        internal static TreeNode[] GetChildren(DirectoryNode node,object innerDoc)
        {
            var children = new List<AbstractTreeNode>();

            var entries = node.Entries;

            while (entries.MoveNext())
            {
                EntryNode entry = entries.Current as EntryNode;
                AbstractTreeNode treeNode;
                if (entry is DirectoryNode)
                {
                    treeNode = new DirectoryTreeNode(entry as DirectoryNode);

                    var o = entry as DirectoryNode;
                }
                else
                {
                    var o = entry as DocumentNode;

                    treeNode = new DocumentTreeNode(entry as DocumentNode);

                    #region handle Excel BIFF records

                    if (treeNode.Text.ToLower() == "workbook")
                    {
                        HandleWorkbook(treeNode, (HSSFWorkbook)innerDoc);
                    }
                    //else if(treeNode.Text.ToLower() == "worddocument")
                    //{
                    //    HandleWord(treeNode, (HWPFDocument)innerDoc);
                    //}

                    #endregion
                }

                children.Add(treeNode);
            }

            children.Sort();

            return children.ToArray();
        }
开发者ID:xoposhiy,项目名称:npoi,代码行数:43,代码来源:DirectoryTreeNode.cs

示例8: CreateFromEmbeddedOleObject

        /// <summary>
        /// Creates an instance of this class from an embedded OLE Object. The OLE Object is expected
        /// to include a stream &quot;{01}Ole10Native&quot; which contains the actual
        /// data relevant for this class.
        /// </summary>
        /// <param name="directory">directory POI Filesystem object</param>
        /// <returns>Returns an instance of this class</returns>
        public static Ole10Native CreateFromEmbeddedOleObject(DirectoryNode directory)
        {
            bool plain = false;

            try
            {
                directory.GetEntry("\u0001Ole10ItemName");
                plain = true;
            }
            catch (FileNotFoundException)
            {
                plain = false;
            }

            DocumentEntry nativeEntry =
               (DocumentEntry)directory.GetEntry(OLE10_NATIVE);
            byte[] data = new byte[nativeEntry.Size];
            directory.CreateDocumentInputStream(nativeEntry).Read(data);

            return new Ole10Native(data, 0);
        }
开发者ID:eatage,项目名称:npoi,代码行数:28,代码来源:Ole10Native.cs

示例9: DirectoryNode

        /// <summary>
        /// Create a DirectoryNode. This method Is not public by design; it
        /// Is intended strictly for the internal use of this package
        /// </summary>
        /// <param name="property">the DirectoryProperty for this DirectoryEntry</param>
        /// <param name="filesystem">the POIFSFileSystem we belong to</param>
        /// <param name="parent">the parent of this entry</param>
        public DirectoryNode(DirectoryProperty property,
                      POIFSFileSystem filesystem,
                      DirectoryNode parent)
            : base(property, parent)
        {
            if (parent == null)
            {
                _path = new POIFSDocumentPath();
            }
            else
            {
                _path = new POIFSDocumentPath(parent._path, new String[]
                {
                    property.Name
                });
            }
            _filesystem = filesystem;
            _entries    = new Hashtable();
            IEnumerator iter = property.Children;

            while (iter.MoveNext())
            {
                Property child     = ( Property ) iter.Current;
                Entry    childNode = null;

                if (child.IsDirectory)
                {
                    childNode = new DirectoryNode(( DirectoryProperty ) child,
                                                  _filesystem, this);
                }
                else
                {
                    childNode = new DocumentNode(( DocumentProperty ) child,
                                                 this);
                }
                _entries[childNode.Name]=childNode;
            }
        }
开发者ID:babywzazy,项目名称:Server,代码行数:45,代码来源:DirectoryNode.cs

示例10: EntryNode

 /// <summary>
 /// Create a DocumentNode. ThIs method Is not public by design; it
 /// Is intended strictly for the internal use of extending classes
 /// </summary>
 /// <param name="property">the Property for this Entry</param>
 /// <param name="parent">the parent of this entry</param>
 protected EntryNode(Property property, DirectoryNode parent)
 {
     _property = property;
     _parent = parent;
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:11,代码来源:EntryNode.cs

示例11: TestWordDocEmbeddedInXls

        public void TestWordDocEmbeddedInXls()
        {
            //throw new NotImplementedException("class NPOIFSFileSystem is not implemented");
            // Open the two filesystems
            DirectoryNode[] files = new DirectoryNode[2];
            files[0] = (new POIFSFileSystem(HSSFTestDataSamples.OpenSampleFileStream("WithEmbeddedObjects.xls"))).Root;
            files[1] = (new NPOIFSFileSystem(HSSFTestDataSamples.OpenSampleFileStream("WithEmbeddedObjects.xls"))).Root;

            // Check the embedded parts
            foreach (DirectoryNode root in files)
            {
                HSSFWorkbook hw = new HSSFWorkbook(root, true);
                IList<HSSFObjectData> objects = hw.GetAllEmbeddedObjects();
                bool found = false;
                for (int i = 0; i < objects.Count; i++)
                {
                    HSSFObjectData embeddedObject = objects[i];
                    if (embeddedObject.HasDirectoryEntry())
                    {
                        DirectoryEntry dir = embeddedObject.GetDirectory();
                        if (dir is DirectoryNode)
                        {
                            DirectoryNode dNode = (DirectoryNode)dir;
                            if (HasEntry(dNode, "WordDocument"))
                            {
                                found = true;
                            }
                        }
                    }
                }
                Assert.IsTrue(found);
            }
        }
开发者ID:mdjasim,项目名称:npoi,代码行数:33,代码来源:TestHSSFWorkbook.cs

示例12: HasEntry

 private bool HasEntry(DirectoryNode dirNode, String entryName)
 {
     try
     {
         dirNode.GetEntry(entryName);
         return true;
     }
     catch (FileNotFoundException)
     {
         return false;
     }
 }
开发者ID:mdjasim,项目名称:npoi,代码行数:12,代码来源:TestHSSFWorkbook.cs

示例13: TestDifferentPOIFS

        public void TestDifferentPOIFS()
        {
            //throw new NotImplementedException("class NPOIFSFileSystem is not implemented");
            // Open the two filesystems
            DirectoryNode[] files = new DirectoryNode[2];
            files[0] = (new POIFSFileSystem(HSSFTestDataSamples.OpenSampleFileStream("Simple.xls"))).Root;
            files[1] = (new NPOIFSFileSystem(HSSFTestDataSamples.OpenSampleFileStream("Simple.xls"))).Root;

            // Open without preserving nodes 
            foreach (DirectoryNode dir in files)
            {
                IWorkbook workbook = new HSSFWorkbook(dir, false);
                ISheet sheet = workbook.GetSheetAt(0);
                ICell cell = sheet.GetRow(0).GetCell(0);
                Assert.AreEqual("replaceMe", cell.RichStringCellValue.String);
            }

            // Now re-check with preserving
            foreach (DirectoryNode dir in files)
            {
                IWorkbook workbook = new HSSFWorkbook(dir, true);
                ISheet sheet = workbook.GetSheetAt(0);
                ICell cell = sheet.GetRow(0).GetCell(0);
                Assert.AreEqual("replaceMe", cell.RichStringCellValue.String);
            }
        }
开发者ID:mdjasim,项目名称:npoi,代码行数:26,代码来源:TestHSSFWorkbook.cs

示例14: GetDataStream

 public override Stream GetDataStream(DirectoryNode dir)
 {
     DocumentInputStream dis = dir.CreateDocumentInputStream("EncryptedPackage");
     _length = dis.ReadLong();
     return new ChunkedCipherInputStream(dis, _length, this);
 }
开发者ID:xiepeixing,项目名称:npoi,代码行数:6,代码来源:AgileDecryptor.cs

示例15: HSSFWorkbook

 /// <summary>
 /// given a POI POIFSFileSystem object, and a specific directory
 /// within it, Read in its Workbook and populate the high and
 /// low level models.  If you're Reading in a workbook...start here.
 /// </summary>
 /// <param name="directory">the POI filesystem directory to Process from</param>
 /// <param name="fs">the POI filesystem that Contains the Workbook stream.</param>
 /// <param name="preserveNodes">whether to preseve other nodes, such as
 /// macros.  This takes more memory, so only say yes if you
 /// need to. If Set, will store all of the POIFSFileSystem
 /// in memory</param>
 public HSSFWorkbook(DirectoryNode directory, POIFSFileSystem fs, bool preserveNodes)
     : this(directory, preserveNodes)
 {
 }
开发者ID:xiepeixing,项目名称:npoi,代码行数:15,代码来源:HSSFWorkbook.cs


注:本文中的NPOI.POIFS.FileSystem.DirectoryNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。