@@ -577,13 +577,23 @@ internal void ReleaseRunspaceHandle(RunspaceHandle runspaceHandle)
577577 }
578578 }
579579
580+ /// <summary>
581+ /// Sets the current working directory of the powershell context. The path should be
582+ /// unescaped before calling this method.
583+ /// </summary>
584+ /// <param name="path"></param>
585+ public void SetWorkingDirectory ( string path )
586+ {
587+ this . currentRunspace . SessionStateProxy . Path . SetLocation ( path ) ;
588+ }
589+
580590 /// <summary>
581591 /// Returns the passed in path with the [ and ] characters escaped. Escaping spaces is optional.
582592 /// </summary>
583593 /// <param name="path">The path to process.</param>
584594 /// <param name="escapeSpaces">Specify True to escape spaces in the path, otherwise False.</param>
585595 /// <returns>The path with [ and ] escaped.</returns>
586- internal static string EscapePath ( string path , bool escapeSpaces )
596+ public static string EscapePath ( string path , bool escapeSpaces )
587597 {
588598 string escapedPath = Regex . Replace ( path , @"(?<!`)\[" , "`[" ) ;
589599 escapedPath = Regex . Replace ( escapedPath , @"(?<!`)\]" , "`]" ) ;
@@ -602,7 +612,7 @@ internal static string EscapePath(string path, bool escapeSpaces)
602612 /// </summary>
603613 /// <param name="path">The path to unescape.</param>
604614 /// <returns>The path with the ` character before [, ] and spaces removed.</returns>
605- internal static string UnescapePath ( string path )
615+ public static string UnescapePath ( string path )
606616 {
607617 if ( ! path . Contains ( "`" ) )
608618 {
0 commit comments