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/TestScriptRunner.cs
C# | Copy Code |
---|
using (TempDirectory dir = new TempDirectory())
using (ScriptRunner runner = new ScriptRunner(ScriptEngine.Language.Cmd, "@ECHO cd"))
{
string output = String.Empty;
runner.OutputReceived += delegate(object o, ProcessOutputEventArgs e) { output += e.Data; };
Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory);
runner.WorkingDirectory = dir.TempPath;
Assert.AreEqual(dir.TempPath, runner.WorkingDirectory);
runner.Run();
Assert.AreEqual(dir.TempPath.TrimEnd('\\', '/'), output.TrimEnd('\\', '/'));
} |
VB.NET | Copy Code |
---|
Using dir As New TempDirectory()
Using runner As New ScriptRunner(ScriptEngine.Language.Cmd, "@ECHO cd")
Dim output As String = [String].Empty
runner.OutputReceived += Function(o As Object, e As ProcessOutputEventArgs) Do
output += e.Data
End Function
Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory)
runner.WorkingDirectory = dir.TempPath
Assert.AreEqual(dir.TempPath, runner.WorkingDirectory)
runner.Run()
Assert.AreEqual(dir.TempPath.TrimEnd("\"C, "/"C), output.TrimEnd("\"C, "/"C))
End Using
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also