title: How to fill textbox with filename from OpenFileDialog?
body: <p>I have a user interface that has a button and a text box. The button opens up OpenFiledDialog where a file is selected. I want to capture the path/filename from the System.Windows.Forms.OpenFileDialog and place it into a System.Windows.Forms.TextBox.</p>
  <pre><code>###############Browse Button################################################################
  $Button3 = New-Object System.Windows.Forms.Button
  $Button3.Location = New-Object System.Drawing.Point(23,219)
  $Button3.Size = New-Object System.Drawing.Size(23,23)
  $Button3.Text = &quot;...&quot;
  $Button3.Add_Click({Get-FileName -initialDirectory &quot;d:\pathname&quot;})
  $Form1.Controls.Add($Button3)
  ###############SpreadSheetBox##################################################################
  $InputBox3 = New-Object System.Windows.Forms.TextBox
  $InputBox3.Location = New-Object System.Drawing.Size(51,219)
  $InputBox3.Size = New-Object System.Drawing.Size(220,310)
  $InputBox3.Multiline= $false
  $Form1.Controls.Add($InputBox3)
  </code></pre>
  <p>The 'browse' button calls the function Get-FileName. Please see my code.</p>
  <pre><code>Function Get-FileName($initialDirectory)
  {   
   [System.Reflection.Assembly]::LoadWithPartialName(&quot;System.windows.forms&quot;) |
   Out-Null
   $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
   $OpenFileDialog.Title = &quot;Choose a spreadsheet&quot;
   $OpenFileDialog.initialDirectory = $initialDirectory
   $OpenFileDialog.filter = &quot;Excel Worksheet (*.xlsx)| *.xlsx&quot;
   $OpenFileDialog.ShowDialog() | Out-Null
   $OpenFileDialog.filename
  </code></pre>
  <p>It doesn't have to be a function that is called; I just want it to work. Currently it is not putting the selected file's path int he textbox.</p>