title: Get File Extension C#
body: <p>I have a dropdown with list of file names. When a file name is selected in the dropdown I do the following </p>
  
  <pre><code>string filename = ddl.SelectedItem.Text;
  string path = "F:\\WorkingCopy\\files\\" + filename +".docx";
  DownloadFile(path,filename);
  </code></pre>
  
  <p>In the file folder files may contain any extension . Since i have hard coded ".docx" in string path everything works fine. But I need to get the extension of the file name with the ddl.SelectedItem.Text alone. Can you tell me how to do this?</p>
  
  <p>Things  I have
  1.) File name without extension in  </p>
  
  <pre><code>string filename = ddl.SelectedItem.Text;
  </code></pre>
  
  <p>2.) Path where the file is located </p>
  
  <pre><code>string path = "F:\\WorkingCopy\\files\\" + filename 
  </code></pre>
  
  <p>I am trying to get the file extension with these . Can any one suggest on this?</p>