@@ -577,13 +577,23 @@ internal void ReleaseRunspaceHandle(RunspaceHandle runspaceHandle)
577
577
}
578
578
}
579
579
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
+
580
590
/// <summary>
581
591
/// Returns the passed in path with the [ and ] characters escaped. Escaping spaces is optional.
582
592
/// </summary>
583
593
/// <param name="path">The path to process.</param>
584
594
/// <param name="escapeSpaces">Specify True to escape spaces in the path, otherwise False.</param>
585
595
/// <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 )
587
597
{
588
598
string escapedPath = Regex . Replace ( path , @"(?<!`)\[" , "`[" ) ;
589
599
escapedPath = Regex . Replace ( escapedPath , @"(?<!`)\]" , "`]" ) ;
@@ -602,7 +612,7 @@ internal static string EscapePath(string path, bool escapeSpaces)
602
612
/// </summary>
603
613
/// <param name="path">The path to unescape.</param>
604
614
/// <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 )
606
616
{
607
617
if ( ! path . Contains ( "`" ) )
608
618
{
0 commit comments