本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}