title: Setting folder to user specified path in C#
body: <p>I am trying to set the current folder of my console application to a user specified path in C# but I can't. I am new to programming and C# is my first language.
  Here is the code so far, I don't know where I am going wrong I have searched the internet for this, followed the steps but it does not set the folder to what the user specifies. What I am trying to do here is to change the folder path to what the user wants to, and set it as the current folder from which the user can then access its files.</p>
  
  <pre><code>   DirectoryInfo folderInfo = new DirectoryInfo("C:\\Windows");
     FileInfo[] files = folderInfo.GetFiles();
  
     Console.WriteLine("Enter Folder Name");
     string userInput = Console.ReadLine();
     FileInfo[] fileType = folderInfo.GetFiles(userInput + "*" + ".", SearchOption.TopDirectoryOnly); //searches for the folder the user has specified 
     Directory.SetCurrentDirectory(userInput);
  
     Console.WriteLine("{0}", userInput );
     Console.ReadLine();
  </code></pre>
  
  <p>The Error I get is </p>
  
  <pre><code>"An unhandled exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll"
  
  Additional information: Could not find a part of the path 'folder name here'.
  </code></pre>
  
  <p>Please bear in mind I am a beginner at this.
  Thank you in advance</p>