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


C# DirectoryInfo.GetDirectory方法代码示例

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


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

示例1: SafeDelete

 public void SafeDelete()
 {
     var dir = new DirectoryInfo("abc");
     dir.SafeDelete(true);
     dir.Refresh();
     Assert.That(dir.SafeDelete(true), Is.False);
     Directory.CreateDirectory(dir.GetDirectory("test2").FullName);
     dir.Refresh();
     Assert.That(dir.SafeDelete(true), Is.True);
     dir.Refresh();
     Assert.That(dir.Exists, Is.False);
 }
开发者ID:exKAZUu,项目名称:Paraiba,代码行数:12,代码来源:DirectoryInfoExtensionsTest.cs

示例2: Clear

 public void Clear()
 {
     var dir = new DirectoryInfo("abc");
     var subdir = dir.GetDirectory("test2");
     subdir.Create();
     using (var fs = new FileStream(subdir.GetFile("test3.txt").FullName, FileMode.Create)) {
         fs.WriteByte(1);
     }
     dir.Clear();
     Assert.That(dir.Exists, Is.True);
     Assert.That(dir.SafeClear(), Is.True);
     Assert.That(dir.SafeDelete(), Is.True);
     dir.Refresh();
     Assert.That(dir.Exists, Is.False);
     Assert.That(dir.SafeClear(), Is.False);
 }
开发者ID:exKAZUu,项目名称:Paraiba,代码行数:16,代码来源:DirectoryInfoExtensionsTest.cs

示例3: VerifyMeasureAndLocalize

        private static void VerifyMeasureAndLocalize(
                string testTargetNames, string inDirPath, string expDirPath, DirectoryInfo outDir) {
            var ret = Inserter.Run(
                    new[] {
                            "-r",
                            outDir.FullName,
                            "-t",
                            outDir.GetDirectory("test").FullName,
                    });
            Assert.That(ret, Is.True);

            // jarとdllファイルが存在するか
            var jar = outDir.GetFile("CoverageWriter.jar");
            Assert.That(jar.Exists, Is.True);

            var covInfoFile = outDir.GetFile(OccfNames.CoverageInfo);
            var testInfoFile = outDir.GetFile(OccfNames.TestInfo);
            var recordFile = outDir.GetFile(OccfNames.Record);
            var resultFile = outDir.GetFile("testresult.txt");

            var targets = Directory.EnumerateFiles(
                    expDirPath, "*.java",
                    SearchOption.AllDirectories)
                    .Concat(
                            Directory.EnumerateFiles(
                                    expDirPath, OccfNames.BackupSuffix,
                                    SearchOption.AllDirectories))
                    .Concat(new[] { covInfoFile.FullName, testInfoFile.FullName });
            foreach (var target in targets) {
                AssertEqualFiles(target, expDirPath, inDirPath);
            }

            Compile(outDir.FullName);
            RunTest(outDir.FullName, testTargetNames);

            var covInfo = CoverageInfo.Read(covInfoFile);
            var testInfo = TestInfo.Read(testInfoFile);

            testInfo.InitializeForStoringData(true);
            BugLocalizer.ReadJUnitResult(resultFile, testInfo);
            CoverageDataReader.ReadFile(testInfo, recordFile);

            var localizeStatements = BugLocalizer.LocalizeStatements(covInfo, testInfo,
                    "metrics/BugLocalization.py");
            Assert.That(localizeStatements, Is.Not.Null);
        }
开发者ID:audioglider,项目名称:OpenCodeCoverageFramework,代码行数:46,代码来源:InsertProgramForJavaTest.cs

示例4: ListDirectories

 private IEnumerable<DirectoryInfo> ListDirectories(DirectoryInfo projectRoot, IEnumerable<string> extraDirectories)
 {
     yield return projectRoot.GetDirectory("bin");
     foreach (var directoryName in extraDirectories)
         yield return projectRoot.GetDirectory(directoryName);
 }
开发者ID:Ag2S,项目名称:Tasty,代码行数:6,代码来源:MvcDotNetProjectMigrationOptions.cs


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