How to get current path/directory in power shell in C#

This is a quick tutorial which explains how can you get the current directory of the power shell navigator. As an example:

Navigator Current Directory

PS C:\Windows\System32>


PS C:\Program Files\>

C:\Program Files

PS E:\MyFile>


This can be done in C# using this piece of code:

using System.Management.Automation;

// Declare the class as a cmdlet and specify an 
  // appropriate verb and noun for the cmdlet name.
  [Cmdlet("Get", "CurrentDirectory")]
  public class GetCurrentDirectoryCommand : Cmdlet
    protected override void BeginProcessing()
      // Write current path