本文整理汇总了C#中System.IO.DirectoryInfo.CreateRecursive方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfo.CreateRecursive方法的具体用法?C# DirectoryInfo.CreateRecursive怎么用?C# DirectoryInfo.CreateRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.DirectoryInfo
的用法示例。
在下文中一共展示了DirectoryInfo.CreateRecursive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDefaultSecretCacheDirectory
public string GetDefaultSecretCacheDirectory()
{
var path = Application.Context.FilesDir.AbsolutePath;
var di = new DirectoryInfo(Path.Combine(path, "Secret"));
if (!di.Exists) di.CreateRecursive();
return di.FullName;
}
示例2: CreatesDirectories
public void CreatesDirectories()
{
string path;
using (Utility.WithEmptyDirectory(out path))
{
var dir = new DirectoryInfo(Path.Combine(path, @"foo\bar\baz"));
dir.CreateRecursive();
Assert.True(dir.Exists);
}
}
示例3: ShouldCreateAppShortcutsBasedOnClientExe
public void ShouldCreateAppShortcutsBasedOnClientExe()
{
string tempDir;
using (acquireEnvVarLock())
using (Utility.WithTempDirectory(out tempDir))
using (setEnvVar("ShortcutDir", tempDir)) {
var di = new DirectoryInfo(Path.Combine(tempDir, "theApp", "app-1.1.0.0"));
di.CreateRecursive();
File.Copy(getPathToShimmerTestTarget(), Path.Combine(di.FullName, "ShimmerIAppUpdateTestTarget.exe"));
var fixture = new UpdateManager("http://lol", "theApp", FrameworkVersion.Net40, tempDir, null, null);
this.Log().Info("Invoking post-install");
var mi = fixture.GetType().GetMethod("runPostInstallOnDirectory", BindingFlags.NonPublic | BindingFlags.Instance);
mi.Invoke(fixture, new object[] { di.FullName, true, new Version(1, 1, 0, 0), Enumerable.Empty<ShortcutCreationRequest>() });
File.Exists(Path.Combine(tempDir, "Foo.lnk")).ShouldBeTrue();
}
}
示例4: IfAppSetupThrowsWeFailTheInstall
public void IfAppSetupThrowsWeFailTheInstall()
{
string tempDir;
using (acquireEnvVarLock())
using (setShouldThrow())
using (Utility.WithTempDirectory(out tempDir)) {
var di = new DirectoryInfo(Path.Combine(tempDir, "theApp", "app-1.1.0.0"));
di.CreateRecursive();
File.Copy(getPathToShimmerTestTarget(), Path.Combine(di.FullName, "ShimmerIAppUpdateTestTarget.exe"));
var fixture = new UpdateManager("http://lol", "theApp", FrameworkVersion.Net40, tempDir, null, null);
bool shouldDie = true;
try {
this.Log().Info("Invoking post-install");
var mi = fixture.GetType().GetMethod("runPostInstallOnDirectory", BindingFlags.NonPublic | BindingFlags.Instance);
mi.Invoke(fixture, new object[] { di.FullName, true, new Version(1, 1, 0, 0), Enumerable.Empty<ShortcutCreationRequest>() });
} catch (TargetInvocationException ex) {
this.Log().Info("Expected to receive Exception", ex);
// NB: This is the exception explicitly rigged in OnAppInstall
if (ex.InnerException is FileNotFoundException) {
shouldDie = false;
} else {
this.Log().ErrorException("Expected FileNotFoundException, didn't get it", ex);
}
}
shouldDie.ShouldBeFalse();
}
}