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


C# FileInfo.IsFile方法代码示例

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


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

示例1: Delete

        public virtual void Delete(string path)
        {
            var fileInfo = new FileInfo(path);

            if (fileInfo.IsFile())
            {
                fileInfo.Delete();

                return;
            }

            var directoryInfo = new DirectoryInfo(path);

            directoryInfo.Delete(true);
        }
开发者ID:kkozmic,项目名称:horn_src,代码行数:15,代码来源:FileSystemProvider.cs

示例2: test001_Initalize

        public void test001_Initalize()
        {
            var gitdir = new DirectoryInfo(trash.FullName + "/.git");
            var objects = new DirectoryInfo(gitdir.FullName + "/objects");
            var objects_pack = new DirectoryInfo(objects.FullName + "/pack");
            var objects_info = new DirectoryInfo(objects.FullName + "/info");
            var refs = new DirectoryInfo(gitdir.FullName + "/refs");
            var refs_heads = new DirectoryInfo(refs.FullName + "/heads");
            var refs_tags = new DirectoryInfo(refs.FullName + "/tags");
            var HEAD = new FileInfo(gitdir.FullName + "/HEAD");

            Assert.IsTrue(trash.IsDirectory(), "Exists " + trash);
            Assert.IsTrue(objects.IsDirectory(), "Exists " + objects);
            Assert.IsTrue(objects_pack.IsDirectory(), "Exists " + objects_pack);
            Assert.IsTrue(objects_info.IsDirectory(), "Exists " + objects_info);
            Assert.AreEqual(2, objects.ListFiles().Length);
            Assert.IsTrue(refs.IsDirectory(), "Exists " + refs);
            Assert.IsTrue(refs_heads.IsDirectory(), "Exists " + refs_heads);
            Assert.IsTrue(refs_tags.IsDirectory(), "Exists " + refs_tags);
            Assert.IsTrue(HEAD.IsFile(), "Exists " + HEAD);
            Assert.AreEqual(23, HEAD.Length);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:22,代码来源:T0003_Basic_Write.cs

示例3: PrescanTwoTrees

        internal void PrescanTwoTrees()
        {
            var visitor = new AbstractIndexTreeVisitor
                              {
                                  VisitEntryAux = (treeEntry, auxEntry, indexEntry, file) =>
                                                   {
                                                       if (treeEntry is Tree || auxEntry is Tree)
                                                       {
                                                           throw new ArgumentException("Can't pass me a tree!");
                                                       }

                                                       ProcessEntry(treeEntry, auxEntry, indexEntry);
                                                   },

                                  FinishVisitTree = (tree, auxTree, currentDirectory) =>
                                                        {
                                                            if (currentDirectory.Length == 0) return;
                                                            if (auxTree == null) return;

                                                            if (_index.GetEntry(currentDirectory) != null)
                                                            {
                                                                Removed.Add(currentDirectory);
                                                            }
                                                        }
                              };

            new IndexTreeWalker(_index, _head, _merge, _root, visitor).Walk();

            // if there's a conflict, don't list it under
            // to-be-removed, since that messed up our next
            // section
            Removed.RemoveAll(removed => Conflicts.Contains(removed));

            foreach (string path in _updated.Keys)
            {
                if (_index.GetEntry(path) == null)
                {
                    FileSystemInfo file = new FileInfo(Path.Combine(_root.DirectoryName(), path));
                    if (file.IsFile())
                    {
                        Conflicts.Add(path);
                    }
                    else if (file.IsDirectory())
                    {
                        CheckConflictsWithFile(file);
                    }
                }
            }

            Conflicts.RemoveAll(conflict => Removed.Contains(conflict));
        }
开发者ID:dev218,项目名称:GitSharp,代码行数:51,代码来源:WorkDirCheckout.cs

示例4: loadIdentity

 private static void loadIdentity(JSch sch, FileInfo priv)
 {
     if (!priv.IsFile()) return;
     try
     {
         sch.addIdentity(priv.FullName);
     }
     catch (JSchException)
     {
         // Instead, pretend the key doesn't exist.
     }
 }
开发者ID:dev218,项目名称:GitSharp,代码行数:12,代码来源:SshConfigSessionFactory.cs

示例5: test002_WriteEmptyTree

 public void test002_WriteEmptyTree()
 {
     // One of our test packs contains the empty tree object. If the pack is
     // open when we Create it we won't write the object file out as a loose
     // object (as it already exists in the pack).
     //
     Core.Repository newdb = createNewEmptyRepo();
     var t = new Tree(newdb);
     t.Accept(new WriteTree(trash, newdb), TreeEntry.MODIFIED_ONLY);
     Assert.AreEqual("4b825dc642cb6eb9a060e54bf8d69288fbee4904", t.Id.Name);
     var o = new FileInfo(newdb.Directory + "/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904");
     Assert.IsTrue(o.IsFile(), "Exists " + o);
     Assert.IsTrue(o.IsReadOnly, "Read-only " + o);
 }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:14,代码来源:T0003_Basic_Write.cs

示例6: test003_WriteShouldBeEmptyTree

        public void test003_WriteShouldBeEmptyTree()
        {
            Tree t = new Tree(db);
            ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
            t.AddFile("should-be-empty").Id = emptyId;
            t.Accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
            Assert.AreEqual("7bb943559a305bdd6bdee2cef6e5df2413c3d30a", t.Id.Name);

            var o = new FileInfo(trash_git + "/objects/7b/b943559a305bdd6bdee2cef6e5df2413c3d30a");
            Assert.IsTrue(o.IsFile(), "Exists " + o);
            Assert.IsTrue(o.IsReadOnly, "Read-only " + o);

            o = new FileInfo(trash_git + "/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391");
            Assert.IsTrue(o.IsFile(), "Exists " + o);
            Assert.IsTrue(o.IsReadOnly, "Read-only " + o);
        }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:16,代码来源:T0003_Basic_Write.cs

示例7: test002_WriteEmptyTree2

 public void test002_WriteEmptyTree2()
 {
     // File shouldn't exist as it is in a test pack.
     //
     var t = new Tree(db);
     t.Accept(new WriteTree(trash, db), TreeEntry.MODIFIED_ONLY);
     Assert.AreEqual("4b825dc642cb6eb9a060e54bf8d69288fbee4904", t.Id.Name);
     var o = new FileInfo(trash_git + "/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904");
     Assert.IsFalse(o.IsFile(), "Exists " + o);
 }
开发者ID:mdekrey,项目名称:GitSharp,代码行数:10,代码来源:T0003_Basic_Write.cs


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