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


C# IDirectory.File方法代码示例

本文整理汇总了C#中IDirectory.File方法的典型用法代码示例。如果您正苦于以下问题:C# IDirectory.File方法的具体用法?C# IDirectory.File怎么用?C# IDirectory.File使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDirectory的用法示例。


在下文中一共展示了IDirectory.File方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyTo

        /// <summary>
        /// Copy "this" directory (<paramref name="a_this"/>) to the given destination directory (<paramref name="a_destination"/>).
        /// </summary>
        /// <param name="a_this">"This" directory.</param>
        /// <param name="a_destination">Destination directory.</param>
        /// <exception cref="NullReferenceException">Thrown if <paramref name="a_this"/> is null.</exception>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="a_destination"/> is null.</exception>
        public static void CopyTo(this IDirectory a_this, IDirectory a_destination)
        {
            #region Argument Validation

            if (a_this == null)
                throw new NullReferenceException(nameof(a_this));

            if (a_destination == null)
                throw new ArgumentNullException(nameof(a_destination));

            #endregion

            a_destination.Create();

            foreach (var file in a_this.Files())
            {
                var dest = a_destination.File(file.Name);
                file.CopyTo(dest);
            }

            foreach (var directory in a_this.Directories())
            {
                var dest = a_destination.Directory(directory.Name);
                directory.CopyTo(dest);
            }
        }
开发者ID:jsmunroe,项目名称:Helpers,代码行数:33,代码来源:DirectoryHelpers.cs

示例2: Run

 public static UserProcess Run(
     IFile file,
     string arguments,
     IDirectory workingDirectory,
     string username,
     string password)
 {
     var outputFile = workingDirectory.File(file.Name() + ".output.log");
     if (outputFile.Exists())
     {
         outputFile.Delete();
     }
     string command = "cmd /c {0} {1} > {2} 2>&1".FormatFrom(
         file.Path, arguments, outputFile);
     
     outputFile.WriteAllText(command + Environment.NewLine);
     var process = Win32ProcessAsUser.CreateProcessWithLogon(command, Environment.UserDomainName, username, password);
     var shellProcess = new UserProcess(process, outputFile);
     return shellProcess;
 }
开发者ID:ryascl,项目名称:design-challenge-server-clr,代码行数:20,代码来源:UserProcess.cs

示例3: CopyInto

 public static IFile CopyInto(this IFile file, IDirectory target, bool overwrite = true)
 {
     return CopyTo(file, target.File(file.Name()));
 }
开发者ID:ryascl,项目名称:design-challenge-server-clr,代码行数:4,代码来源:FileSystemAbstractionExtensions.cs

示例4: RunTests

        private AssessmentResult RunTests(IDirectory testDirectory, int port)
        {
            const string testOutputFileName = "features_report.html";
            var ruby = new PathFile(_settings.Env.RubyBin, "ruby.exe");
            var cuke = new PathFile(_settings.Env.RubyBin, "cucumber");
            string args = "{0} {1} --strict --format pretty --format html --out={2} {3}={4}"
                .FormatFrom(
                cuke, 
                testDirectory.Path, 
                testOutputFileName,
                "features_test_port", 
                port);

            var stringWriter = new StringWriter();
            var syncWriter = TextWriter.Synchronized(stringWriter);
            using (var process = _shell.StartBackgroundProcess(
                new ProcessStartInfo(ruby.Path, args)
                {
                    UseShellExecute = false,
                    WorkingDirectory = testDirectory.Path,
                    RedirectStandardOutput = true,
                    RedirectStandardError = true
                },
                syncWriter.WriteLine,
                syncWriter.WriteLine))
            {
                AssessmentResult assessmentResult;
                if (!process.WaitForExit(30000))
                {
                    assessmentResult = new AssessmentResult(AssessmentOutcome.TestFailure)
                    {
                        Message = "Timeout waiting for test completion"
                    };
                }
                else
                {
                    if (process.ExitCode == 0)
                    {
                        assessmentResult = new AssessmentResult(AssessmentOutcome.Success)
                        {
                            Message = "Tests passed"
                        };
                    }
                    else
                    {
                        assessmentResult = new AssessmentResult(AssessmentOutcome.TestFailure)
                        {
                            Message = "Tests failed"
                        };
                    }
                }

                try
                {
                    if (!process.HasExited)
                    {
                        process.Kill();
                    }
                }
                catch(Exception ex)
                {
                    _log.DebugFormat("Failed to kill test process {0} {1}: {2}",
                        ruby.Path,
                        args,
                        ex.Summary());
                }

                var testOutputFile = testDirectory.File(testOutputFileName);
                if (testOutputFile.Exists())
                {
                    assessmentResult.TestOutput = testOutputFile.ReadAllText();
                    assessmentResult.TestOutputFormat = TestOutputFormat.Html;
                }
                assessmentResult.BuildOutput = stringWriter.ToString();
                return assessmentResult;
            }
        }
开发者ID:ryascl,项目名称:design-challenge-server-clr,代码行数:77,代码来源:SolutionRunner.cs


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