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


C# DirectoryEntry.GetEntry方法代码示例

本文整理汇总了C#中DirectoryEntry.GetEntry方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryEntry.GetEntry方法的具体用法?C# DirectoryEntry.GetEntry怎么用?C# DirectoryEntry.GetEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DirectoryEntry的用法示例。


在下文中一共展示了DirectoryEntry.GetEntry方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

 /**
  * <p>Creates the most specific {@link PropertySet} from an entry
  *  in the specified POIFS Directory. This is preferrably a {@link
  * DocumentSummaryInformation} or a {@link SummaryInformation}. If
  * the specified entry does not contain a property Set stream, an 
  * exception is thrown. If no entry is found with the given name,
  * an exception is thrown.</p>
  *
  * @param dir The directory to find the PropertySet in
  * @param name The name of the entry Containing the PropertySet
  * @return The Created {@link PropertySet}.
  * @if there is no entry with that name
  * @if the stream does not
  * contain a property Set.
  * @if some I/O problem occurs.
  * @exception EncoderFallbackException if the specified codepage is not
  * supported.
  */
 public static PropertySet Create(DirectoryEntry dir, String name)
 {
     Stream inp = null;
     try
     {
         DocumentEntry entry = (DocumentEntry)dir.GetEntry(name);
         inp = new DocumentInputStream(entry);
         try
         {
             return Create(inp);
         }
         catch (MarkUnsupportedException e) { return null; }
     }
     finally
     {
         if (inp != null) inp.Close();
     }
 }
开发者ID:newlysoft,项目名称:npoi,代码行数:36,代码来源:PropertySetFactory.cs

示例2: Write

 /// <summary>
 /// Writes a property Set To a document in a POI filesystem directory
 /// </summary>
 /// <param name="dir">The directory in the POI filesystem To Write the document To.</param>
 /// <param name="name">The document's name. If there is alReady a document with the
 /// same name in the directory the latter will be overwritten.</param>
 public virtual void Write(DirectoryEntry dir, String name)
 {
     /* If there is alReady an entry with the same name, Remove it. */
     try
     {
         Entry e = dir.GetEntry(name);
         e.Delete();
     }
     catch (FileNotFoundException)
     {
         /* Entry not found, no need To Remove it. */
     }
     /* Create the new entry. */
     dir.CreateDocument(name, GetStream());
 }
开发者ID:xiepeixing,项目名称:npoi,代码行数:21,代码来源:MutablePropertySet.cs

示例3: SetUp

        public void SetUp()
        {
            bout = new MemoryStream();
            poifs = new POIFSFileSystem();
            dir = poifs.Root;
            dsi = null;
            try
            {
                DocumentEntry dsiEntry = (DocumentEntry)
                    dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
                DocumentInputStream dis = new DocumentInputStream(dsiEntry);
                PropertySet ps = new PropertySet(dis);
                dis.Close();
                dsi = new DocumentSummaryInformation(ps);


            }
            catch (FileNotFoundException)
            {
                /* There is no document summary information yet. We have to Create a
                 * new one. */
                dsi = PropertySetFactory.CreateDocumentSummaryInformation();
                Assert.IsNotNull(dsi);
            }
            catch (IOException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }
            catch (NoPropertySetStreamException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }
            catch (MarkUnsupportedException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }
            catch (UnexpectedPropertySetTypeException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }
            Assert.IsNotNull(dsi);
            try
            {
                DocumentEntry dsiEntry = (DocumentEntry)
                    dir.GetEntry(SummaryInformation.DEFAULT_STREAM_NAME);
                DocumentInputStream dis = new DocumentInputStream(dsiEntry);
                PropertySet ps = new PropertySet(dis);
                dis.Close();
                si = new SummaryInformation(ps);


            }
            catch (FileNotFoundException)
            {
                /* There is no document summary information yet. We have to Create a
                 * new one. */
                si = PropertySetFactory.CreateSummaryInformation();
                Assert.IsNotNull(si);
            }
            catch (IOException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }
            catch (NoPropertySetStreamException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }
            catch (MarkUnsupportedException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }
            catch (UnexpectedPropertySetTypeException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }
            Assert.IsNotNull(dsi);
        }
开发者ID:ctddjyds,项目名称:npoi,代码行数:85,代码来源:TestMetaDataIPI.cs

示例4: CloseAndReOpen

        /**
         * Closes the MemoryStream and Reads it into a MemoryStream.
         * When finished writing information this method is used in the Tests to
         * start Reading from the Created document and then the see if the results match.
         *
         */
        private void CloseAndReOpen()
        {

            try
            {
                dsi.Write(dir, DocumentSummaryInformation.DEFAULT_STREAM_NAME);
                si.Write(dir, SummaryInformation.DEFAULT_STREAM_NAME);
            }
            catch (WritingNotSupportedException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }
            catch (IOException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }

            si = null;
            dsi = null;
            try
            {

                poifs.WriteFileSystem(bout);
                bout.Flush();

            }
            catch (IOException)
            {

                ////e.printStackTrace();
                Assert.Fail();
            }

            Stream is1 = new MemoryStream(bout.ToArray());
            Assert.IsNotNull(is1);
            poifs = null;
            try
            {
                poifs = new POIFSFileSystem(is1);
            }
            catch (IOException)
            {

                ////e.printStackTrace();
                Assert.Fail();
            }
            try
            {
                is1.Close();
            }
            catch (IOException)
            {
                ////e.printStackTrace();
                Assert.Fail();
            }
            Assert.IsNotNull(poifs);
            /* Read the document summary information. */
            dir = poifs.Root;

            try
            {
                DocumentEntry dsiEntry = (DocumentEntry)
                    dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
                DocumentInputStream dis = new DocumentInputStream(dsiEntry);
                PropertySet ps = new PropertySet(dis);
                dis.Close();
                dsi = new DocumentSummaryInformation(ps);
            }
            catch (FileNotFoundException ex)
            {
                Assert.Fail(ex.Message);
            }
            catch (IOException e)
            {
                //e.printStackTrace();
                Assert.Fail(e.Message);
            }
            catch (NoPropertySetStreamException e)
            {
                //e.printStackTrace();
                Assert.Fail(e.Message);
            }
            catch (MarkUnsupportedException e)
            {
                //e.printStackTrace();
                Assert.Fail(e.Message);
            }
            catch (UnexpectedPropertySetTypeException e)
            {
                //e.printStackTrace();
                Assert.Fail(e.Message);
            }
//.........这里部分代码省略.........
开发者ID:ctddjyds,项目名称:npoi,代码行数:101,代码来源:TestMetaDataIPI.cs

示例5: AreDirectoriesIdentical

        /**
         * Checks to see if the two Directories hold the same contents.
         * For this to be true, they must have entries with the same names,
         *  no entries in one but not the other, and the size+contents
         *  of each entry must match, and they must share names.
         * To exclude certain parts of the Directory from being checked,
         *  use a {@link FilteringDirectoryNode}
         */
        public static bool AreDirectoriesIdentical(DirectoryEntry dirA, DirectoryEntry dirB)
        {
            // First, check names
            if (!dirA.Name.Equals(dirB.Name))
            {
                return false;
            }

            // Next up, check they have the same number of children
            if (dirA.EntryCount != dirB.EntryCount)
            {
                return false;
            }

            // Next, check entries and their types/sizes
            Dictionary<String, int> aSizes = new Dictionary<String, int>();
            int isDirectory = -12345;
            foreach (Entry a in dirA)
            {
                String aName = a.Name;
                if (a.IsDirectoryEntry)
                {
                    aSizes.Add(aName, isDirectory);
                }
                else
                {
                    aSizes.Add(aName, ((DocumentNode)a).Size);
                }
            }
            foreach (Entry b in dirB)
            {
                String bName = b.Name;
                if (!aSizes.ContainsKey(bName))
                {
                    // In B but not A
                    return false;
                }

                int size;
                if (b.IsDirectoryEntry)
                {
                    size = isDirectory;
                }
                else
                {
                    size = ((DocumentNode)b).Size;
                }
                if (size != aSizes[(bName)])
                {
                    // Either the wrong type, or they're different sizes
                    return false;
                }

                // Track it as checked
                aSizes.Remove(bName);
            }
            if (!(aSizes.Count == 0))
            {
                // Nodes were in A but not B
                return false;
            }

            // If that passed, check entry contents
            foreach (Entry a in dirA)
            {
                try
                {
                    Entry b = dirB.GetEntry(a.Name);
                    bool match;
                    if (a.IsDirectoryEntry)
                    {
                        match = AreDirectoriesIdentical(
                              (DirectoryEntry)a, (DirectoryEntry)b);
                    }
                    else
                    {
                        match = AreDocumentsIdentical(
                              (DocumentEntry)a, (DocumentEntry)b);
                    }
                    if (!match) return false;
                }
                catch (FileNotFoundException)
                {
                    // Shouldn't really happen...
                    return false;
                }
                catch (IOException)
                {
                    // Something's messed up with one document, not a match
                    return false;
                }
            }
//.........这里部分代码省略.........
开发者ID:Reinakumiko,项目名称:npoi,代码行数:101,代码来源:EntryUtils.cs


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