當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。