title: Convert YYYYMMDD string date to a datetime value
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1592653/convert-string-to-datetime-in-c-sharp">Convert string to DateTime in c#</a>  </p>
  </blockquote>
  
  
  
  <p>A question</p>
  
  <p>I got a string value that actually get from directoryInfo.
  What i wanted to accomplish is to convert the string value to a date value for making comparison.</p>
  
  <p>The folder name is sample like this C:\FOLD\20111120
  and properly another folder path is like this 
  C:\FOLD\20111021</p>
  
  <p>20111120 is actually a date format. I am trying to convert it into date format to made some comparison decide to deleting the whole directory or not.</p>
  
  <p>I think i shall paste my code here</p>
  
  <pre><code>DirectoryInfo dir = new DirectoryInfo(_FolderPath);
  
  foreach (DirectoryInfo f in dir.GetDirectories())
  {
       String folderName = f.ToString();
       DateTime ConDt = Convert.ToDateTime(folderName);
       Console.WriteLine(ConDt);
       Console.WriteLine(ConDt.GetType());
     //Console.WriteLine(folderName.GetType());
     //Console.WriteLine(f.GetType());
  }
  </code></pre>
  
  <p>I tried with Convert.toDatetime() and i get error that unable to made the converstion.How can i do so with this?</p>