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