本文整理匯總了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();
}
}