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


C# DirectoryInfo.CreateRecursive方法代码示例

本文整理汇总了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;
        }
开发者ID:ErikEJ,项目名称:Akavache,代码行数:8,代码来源:AndroidFilesystemProvider.cs

示例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);
     }
 }
开发者ID:okkk,项目名称:Akavache,代码行数:10,代码来源:UtilityTests.cs

示例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();
            }
        }
开发者ID:erwinchan,项目名称:Shimmer,代码行数:20,代码来源:ApplyReleasesTests.cs

示例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();
            }
        }
开发者ID:erwinchan,项目名称:Shimmer,代码行数:34,代码来源:ApplyReleasesTests.cs


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