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


C# FileSystem.NPOIFSFileSystem类代码示例

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


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

示例1: Test53475

        public void Test53475()
        {
            try
            {
                Biff8EncryptionKey.CurrentUserPassword = (/*setter*/"solrcell");
                FileStream file = POIDataSamples.GetDocumentInstance().GetFile("bug53475-password-is-solrcell.docx");
                NPOIFSFileSystem filesystem = new NPOIFSFileSystem(file, true);
/*
                // Check the encryption details
                EncryptionInfo info = new EncryptionInfo(filesystem);
                Assert.AreEqual(128, info.Header.KeySize);
                Assert.AreEqual(EncryptionHeader.ALGORITHM_AES_128, info.Header.Algorithm);
                Assert.AreEqual(EncryptionHeader.HASH_SHA1, info.Header.HashAlgorithm);

                // Check it can be decoded
                Decryptor d = Decryptor.GetInstance(info);
                Assert.IsTrue("Unable to Process: document is encrypted", d.VerifyPassword("solrcell"));

                // Check we can read the word document in that
                InputStream dataStream = d.GetDataStream(filesystem);
                OPCPackage opc = OPCPackage.Open(dataStream);
                XWPFDocument doc = new XWPFDocument(opc);
                XWPFWordExtractor ex = new XWPFWordExtractor(doc);
                String text = ex.Text;
                Assert.IsNotNull(text);
                Assert.AreEqual("This is password protected Word document.", text.Trim());
                ex.Close();
 */
            }
            finally
            {
                Biff8EncryptionKey.CurrentUserPassword = (/*setter*/null);
            }
        }
开发者ID:eatage,项目名称:npoi,代码行数:34,代码来源:TestXWPFBugs.cs

示例2: NPropertyTable

 public NPropertyTable(HeaderBlock headerBlock, NPOIFSFileSystem fileSystem)
     :base(headerBlock, 
             BuildProperties( (new NPOIFSStream(fileSystem, headerBlock.PropertyStart)).GetEnumerator(),headerBlock.BigBlockSize)
     )
 {
     _bigBigBlockSize = headerBlock.BigBlockSize;
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:7,代码来源:NPropertyTable.cs

示例3: get512and4kFileAndInput

     /**
 * Returns test files with 512 byte and 4k block sizes, loaded
 *  both from InputStreams and Files
 */
     protected NPOIFSFileSystem[] get512and4kFileAndInput()
     {
         NPOIFSFileSystem fsA = new NPOIFSFileSystem(_inst.GetFile("BlockSize512.zvi"));
         NPOIFSFileSystem fsB = new NPOIFSFileSystem(_inst.OpenResourceAsStream("BlockSize512.zvi"));
         NPOIFSFileSystem fsC = new NPOIFSFileSystem(_inst.GetFile("BlockSize4096.zvi"));
         NPOIFSFileSystem fsD = new NPOIFSFileSystem(_inst.OpenResourceAsStream("BlockSize4096.zvi"));
         return new NPOIFSFileSystem[] { fsA, fsB, fsC, fsD };
     }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:12,代码来源:TestNPOIFSFileSystem.cs

示例4: NPOIFSMiniStore

        public NPOIFSMiniStore(NPOIFSFileSystem filesystem, RootProperty root,
             List<BATBlock> sbats, HeaderBlock header)
        {
            this._filesystem = filesystem;
            this._sbat_blocks = sbats;
            this._header = header;
            this._root = root;

            this._mini_stream = new NPOIFSStream(filesystem, root.StartBlock);
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:10,代码来源:NPOIFSMiniStore.cs

示例5: NPOIFSDocument

        /**
         * Constructor for a new Document
         *
         * @param name the name of the POIFSDocument
         * @param stream the InputStream we read data from
         */
        public NPOIFSDocument(String name, NPOIFSFileSystem filesystem, Stream stream)
        {
            this._filesystem = filesystem;
            // sotre it
            int length = Store(stream);

            // Build the property for it
            this._property = new DocumentProperty(name, length);
            _property.StartBlock = _stream.GetStartBlock();
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:16,代码来源:NPOIFSDocument.cs

示例6: NPOIFSDocument

        /**
         * Constructor for an existing Document 
         */
        public NPOIFSDocument(DocumentProperty property, NPOIFSFileSystem filesystem)
        {
            this._property = property;
            this._filesystem = filesystem;

            if (property.Size < POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE)
            {
                _stream = new NPOIFSStream(_filesystem.GetMiniStore(), property.StartBlock);
                _block_size = _filesystem.GetMiniStore().GetBlockStoreBlockSize();
            }
            else
            {
                _stream = new NPOIFSStream(_filesystem, property.StartBlock);
                _block_size = _filesystem.GetBlockStoreBlockSize();
            }
        }
开发者ID:xoposhiy,项目名称:npoi,代码行数:19,代码来源:NPOIFSDocument.cs

示例7: TestBasicOpen

        public void TestBasicOpen()
        {
            NPOIFSFileSystem fsA, fsB;
            fsA = new NPOIFSFileSystem(_inst.GetFile("BlockSize512.zvi"));
            fsB = new NPOIFSFileSystem(_inst.OpenResourceAsStream("BlockSize512.zvi"));

            foreach (NPOIFSFileSystem fs in new NPOIFSFileSystem[] { fsA, fsB })
            {
                Assert.AreEqual(512, fs.GetBigBlockSize());
            }

            fsA = new NPOIFSFileSystem(_inst.GetFile("BlockSize4096.zvi"));
            fsB = new NPOIFSFileSystem(_inst.OpenResourceAsStream("BlockSize4096.zvi"));

            foreach (NPOIFSFileSystem fs in new NPOIFSFileSystem[] { fsA, fsB })
            {
                Assert.AreEqual(4096, fs.GetBigBlockSize());
            }
        }
开发者ID:hanwangkun,项目名称:npoi,代码行数:19,代码来源:TestNPOIFSFileSystem.cs

示例8: assertBATCount

 protected static void assertBATCount(NPOIFSFileSystem fs, int expectedBAT, int expectedXBAT)
 {
     int foundBAT = 0;
     int foundXBAT = 0;
     int sz = (int)(fs.Size / fs.GetBigBlockSize());
     for (int i = 0; i < sz; i++)
     {
         if (fs.GetNextBlock(i) == POIFSConstants.FAT_SECTOR_BLOCK)
         {
             foundBAT++;
         }
         if (fs.GetNextBlock(i) == POIFSConstants.DIFAT_SECTOR_BLOCK)
         {
             foundXBAT++;
         }
     }
     Assert.AreEqual(expectedBAT, foundBAT, "Wrong number of BATs");
     Assert.AreEqual(expectedXBAT, foundXBAT, "Wrong number of XBATs with " + expectedBAT + " BATs");
 }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:19,代码来源:TestNPOIFSFileSystem.cs

示例9: openSamples

        protected DirectoryNode[] openSamples(Stream[] inps, bool oldFails)
        {
            NPOIFSFileSystem nfs = new NPOIFSFileSystem(inps[0]);
            if (openedFSs == null) openedFSs = new List<NPOIFSFileSystem>();
            openedFSs.Add(nfs);

            POIFSFileSystem ofs = null;
            try
            {
                ofs = new POIFSFileSystem(inps[1]);
                if (oldFails) Assert.Fail("POIFSFileSystem should have failed but didn't");
            }
            catch (Exception e)
            {
                if (!oldFails) throw e;
            }

            if (ofs == null) return new DirectoryNode[] { nfs.Root };
            return new DirectoryNode[] { ofs.Root, nfs.Root };
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:20,代码来源:TestFileSystemBugs.cs

示例10: TestReadTinyStream

        public void TestReadTinyStream()
        {
            NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.GetFile("BlockSize512.zvi"));
            
            // 98 is actually the last block in a two block stream...
            NPOIFSStream stream = new NPOIFSStream(fs, 98);
            IEnumerator<ByteBuffer> i = stream.GetBlockIterator();
            Assert.AreEqual(true, i.MoveNext());
            ByteBuffer b = i.Current;
            Assert.AreEqual(false, i.MoveNext());

            // Check the contents
            Assert.AreEqual((byte)0x81, b[0]);
            Assert.AreEqual((byte)0x00, b[1]);
            Assert.AreEqual((byte)0x00, b[2]);
            Assert.AreEqual((byte)0x00, b[3]);
            Assert.AreEqual((byte)0x82, b[4]);
            Assert.AreEqual((byte)0x00, b[5]);
            Assert.AreEqual((byte)0x00, b[6]);
            Assert.AreEqual((byte)0x00, b[7]);
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:21,代码来源:TestNPOIFSStream.cs

示例11: TestReadFailsOnLoop

        public void TestReadFailsOnLoop()
        {
            NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.GetFile("BlockSize512.zvi"));

            // Hack the FAT so that it goes 0->1->2->0
            fs.SetNextBlock(0, 1);
            fs.SetNextBlock(1, 2);
            fs.SetNextBlock(2, 0);

            // Now try to read
            NPOIFSStream stream = new NPOIFSStream(fs, 0);
            IEnumerator<ByteBuffer> i = stream.GetBlockIterator();
            //1st read works
            Assert.AreEqual(true, i.MoveNext());

            // 1st read works
              //  i.MoveNext();
            // 2nd read works
            Assert.AreEqual(true, i.MoveNext());

              // i.MoveNext();
              //  Assert.AreEqual(true, i.MoveNext());

            // 3rd read works
            //i.MoveNext();
            Assert.AreEqual(true, i.MoveNext());

            // 4th read blows up as it loops back to 0
            try
            {
                i.MoveNext();
                Assert.AreEqual(true, i.MoveNext());
                Assert.Fail("Loop should have been detected but wasn't!");
            }
            catch (Exception)
            {
                // Good, it was detected
            }
            // Assert.AreEqual(true, i.MoveNext());
        }
开发者ID:89sos98,项目名称:npoi,代码行数:40,代码来源:TestNPOIFSStream.cs

示例12: TestReadShortStream

        public void TestReadShortStream()
        {
            NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.GetFile("BlockSize512.zvi"));

            // 97 -> 98 -> end
            NPOIFSStream stream = new NPOIFSStream(fs, 97);
            IEnumerator<ByteBuffer> i = stream.GetBlockIterator();

            Assert.AreEqual(true, i.MoveNext());

           // i.MoveNext();
            ByteBuffer b97 = i.Current;
            Assert.AreEqual(true, i.MoveNext());

            //i.MoveNext();
            ByteBuffer b98 = i.Current;
            Assert.AreEqual(false, i.MoveNext());

            // Check the contents of the 1st block
            Assert.AreEqual((byte)0x01, b97[0]);
            Assert.AreEqual((byte)0x00, b97[1]);
            Assert.AreEqual((byte)0x00, b97[2]);
            Assert.AreEqual((byte)0x00, b97[3]);
            Assert.AreEqual((byte)0x02, b97[4]);
            Assert.AreEqual((byte)0x00, b97[5]);
            Assert.AreEqual((byte)0x00, b97[6]);
            Assert.AreEqual((byte)0x00, b97[7]);

            // Check the contents of the 2nd block
            Assert.AreEqual((byte)0x81, b98[0]);
            Assert.AreEqual((byte)0x00, b98[1]);
            Assert.AreEqual((byte)0x00, b98[2]);
            Assert.AreEqual((byte)0x00, b98[3]);
            Assert.AreEqual((byte)0x82, b98[4]);
            Assert.AreEqual((byte)0x00, b98[5]);
            Assert.AreEqual((byte)0x00, b98[6]);
            Assert.AreEqual((byte)0x00, b98[7]);

            fs.Close();
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:40,代码来源:TestNPOIFSStream.cs

示例13: TestFiles

        public void TestFiles()
        {
            FileStream[] files = {
            // bug 51891
            POIDataSamples.GetPOIFSInstance().GetFile("multimedia.doc"),
            // tika bug 1072
            POIDataSamples.GetPOIFSInstance().GetFile("20-Force-on-a-current-S00.doc"),
            // other files Containing ole10native records ...
            POIDataSamples.GetDocumentInstance().GetFile("Bug53380_3.doc"),
            POIDataSamples.GetDocumentInstance().GetFile("Bug47731.doc")
        };

            foreach (FileStream f in files)
            {
                NPOIFSFileSystem fs = new NPOIFSFileSystem(f,null, true, true);
                List<Entry> entries = new List<Entry>();
                FindOle10(entries, fs.Root, "/", "");

                foreach (Entry e in entries)
                {
                    MemoryStream bosExp = new MemoryStream();
                    Stream is1 = ((DirectoryNode)e.Parent).CreateDocumentInputStream(e);
                    IOUtils.Copy(is1, bosExp);
                    is1.Close();

                    Ole10Native ole = Ole10Native.CreateFromEmbeddedOleObject((DirectoryNode)e.Parent);

                    MemoryStream bosAct = new MemoryStream();
                    ole.WriteOut(bosAct);

                    //assertThat(bosExp.ToByteArray(), EqualTo(bosAct.ToByteArray()));
                    Assert.IsTrue(Arrays.Equals(bosExp.ToArray(), bosAct.ToArray()));
                }

                fs.Close();
            }
        }
开发者ID:Reinakumiko,项目名称:npoi,代码行数:37,代码来源:TestOle10Native.cs

示例14: EncryptionInfo

 public EncryptionInfo(NPOIFSFileSystem fs)
     : this(fs.Root)
 {
 }
开发者ID:JnS-Software-LLC,项目名称:npoi,代码行数:4,代码来源:EncryptionInfo.cs

示例15: TestWriteFailsOnLoop

        public void TestWriteFailsOnLoop()
        {
            NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.GetFile("BlockSize512.zvi"));

            // Hack the FAT so that it goes 0->1->2->0
            fs.SetNextBlock(0, 1);
            fs.SetNextBlock(1, 2);
            fs.SetNextBlock(2, 0);

            // Try to write a large amount, should fail on the write
            byte[] data = new byte[512 * 4];
            NPOIFSStream stream = new NPOIFSStream(fs, 0);
            try
            {
                stream.UpdateContents(data);
                Assert.Fail("Loop should have been detected but wasn't!");
            }
            catch (Exception) { }

            // Now reset, and try on a small bit
            // Should fail during the freeing set
            fs.SetNextBlock(0, 1);
            fs.SetNextBlock(1, 2);
            fs.SetNextBlock(2, 0);

            data = new byte[512];
            stream = new NPOIFSStream(fs, 0);
            try
            {
                stream.UpdateContents(data);
                Assert.Fail("Loop should have been detected but wasn't!");
            }
            catch (Exception) { }
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:34,代码来源:TestNPOIFSStream.cs


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