title: C# Ask user in which directory are PDF's that need to be merged. Then ask user What the new Subfolder will be called where the Merged PDF's will go?
body: <p>So i came up with C# code that goes to a directory, searches for the PDF file name and its complimentary PDF File that has a _1 and merges those into a folder within that directory called "Merge"</p>
  
  <pre><code>  using PdfSharp.Pdf;
      using PdfSharp.Pdf.IO;
      using System;
      using System.Collections.Generic;
      using System.IO;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      namespace ConsoleApp1
      {
          class Program
          {
                     //private const string dir = @"C:\Users\XBorja\Desktop\IMAGES\";
          static void Main(string[] args)
          {
              Console.WriteLine("Please Enter Location");
              var dir = Console.ReadLine();
              File.SetAttributes(dir, FileAttributes.Normal);
              string[] files = Directory.GetFiles(dir, "*.pdf");
              IEnumerable&lt;IGrouping&lt;string, string&gt;&gt; groups = files.GroupBy(n =&gt; n.Split('.')[0].Split('_')[0]);
              //string f = files[0].Split('_')[0];
              foreach (var items in groups)
                  {
                      Console.WriteLine(items.Key);
                      PdfDocument outputPDFDocument = new PdfDocument();
                      foreach (var pdfFile in items)
                      {
                          Merge(outputPDFDocument, pdfFile);
                      }
                      outputPDFDocument.Save(Path.GetDirectoryName(items.Key) + @"\Merge\" + Path.GetFileNameWithoutExtension(items.Key) + ".pdf");
                  }
                  Console.ReadKey();
              }
              private static void Merge(PdfDocument outputPDFDocument, string pdfFile)
              {
                  PdfDocument inputPDFDocument = PdfReader.Open(pdfFile, PdfDocumentOpenMode.Import);
                  outputPDFDocument.Version = inputPDFDocument.Version;
                  foreach (PdfPage page in inputPDFDocument.Pages)
                  {
                      outputPDFDocument.AddPage(page);
                  }
              }
          }
      }
  </code></pre>
  
  <p>This works great but i would prefer if instead of it being hard coded that it prompts the user by asking which/where the directory is that the PDF's are located to merge.  Then once it does that, ask the user what the new subfolder will be named that the merged pdf's will go to. </p>
  
  <p>I'm fairly new to C#</p>