CSharpTest.Net
WorkingDirectory Property
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class : WorkingDirectory Property

Glossary Item Box

Gets or sets the initial working directory for the process.

Syntax

Visual Basic (Declaration) 
Public Property WorkingDirectory As String
C# 
public string WorkingDirectory {get; set;}

Example

Library/Library.Test/TestAssemblyRunner.cs

C#Copy Code
using (TempDirectory dir = new TempDirectory())
using (AssemblyRunner runner = new AssemblyRunner(Exe))
{
    List<string> lines = new List<string>();
    runner.OutputReceived += delegate(Object o, ProcessOutputEventArgs e) { lines.Add(e.Data); };

    Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory);
    runner.WorkingDirectory = dir.TempPath;
    Assert.AreEqual(dir.TempPath, runner.WorkingDirectory);

    int exitCode = runner.Run();
    Assert.AreEqual(0, exitCode);
    Assert.AreEqual("WorkingDirectory = " + dir.TempPath, lines[0]);
}
VB.NETCopy Code
Using dir As New TempDirectory()
    Using runner As New AssemblyRunner(Exe)
        Dim lines As New List(Of String)()
        runner.OutputReceived += Function(o As [Object], e As ProcessOutputEventArgs) Do
            lines.Add(e.Data)
        End Function

        Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory)
        runner.WorkingDirectory = dir.TempPath
        Assert.AreEqual(dir.TempPath, runner.WorkingDirectory)

        Dim exitCode As Integer = runner.Run()
        Assert.AreEqual(0, exitCode)
        Assert.AreEqual("WorkingDirectory = " + dir.TempPath, lines(0))
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys