title: How do I add a form to a console app so that user can select file?
body: <p>I have created a console application and have it working the way I want it to. Using the "Add Item" > "Add Windows Form" option in VS2010, it has automatically created what I need. I have added a button and code to retrieve an Excel file (below) My question is: </p>
  
  <p>How do I take the file they have created and use it in my program.cs "Main" area?</p>
  
  <p>The code for the OpenFileDialog button click event, from the Form1.cs:</p>
  
  <pre><code>private void btnSelect_Click(object sender, EventArgs e)
  {
  OFD.openFileDialog OFD = new OpenFileDialog();
  OFD.Multiselect = false;
  OFD.Title = "Open Excel Document";
  OFD.Filter = "Excel Document|*.xlsx;*.xls";
  OFD.ShowDialog();
  string docPath = OFD.FileName;
  }
  </code></pre>
  
  <p>That part of my static main event I wish to make "docPath" from the program.cs file</p>
  
  <pre><code>static void Main(string[] args)
      {
          var excel = new ExcelQueryFactory();
          excel.FileName = @"C:\Users\Christopher\Desktop\BookData\TestResults.xls";
         &lt;...code executed on opened excel file...&gt;
       }
  </code></pre>
  
  <p>Thank you for your time. </p>
  
  <p><strong>This is my completed solution:</strong> </p>
  
  <pre><code>class Program
  {
      [STAThread]
      static void Main(string[] args)
      {
  
          var excel = new ExcelQueryFactory();
          OpenFileDialog OFD = new OpenFileDialog();
          OFD.Multiselect = false;
          OFD.Title = "Open Excel Document";
          OFD.Filter = "Excel Document|*.xlsx;*.xls";
          OFD.ShowDialog();
          string filePath = OFD.FileName;
          excel.FileName= filePath.ToString();
          &lt;.the rest of my program is below...&gt;
      }  
  }
  </code></pre>