title: How to find folders and files by its partial name c#
body: <p>in a specific folder of my hard drive i have stored many other sub folder and files. now i want to list those folders and files name by their partial name.</p>
  
  <pre><code>for example
  --------------
  c webapi xx           folder
  c mvctutorial xx      folder
  done webapi xx        folder
  webapi done           folder
  webapi.zip            file
  mvc.iso               file
  </code></pre>
  
  <p>now when i like to search by partial name <strong>webapi</strong> then i want to get list of files and folders name which has webapi word. i want to show their full folder or file name in grid with their full path and size. like below way.</p>
  
  <pre><code>Name                  Type       location    Size
  -----                 ------     ---------   -------
  c webapi xx           folder     c:\test1    2 KB
  c mvctutorial xx      folder     c:\test3    3 KB
  done webapi xx        folder     c:\test1    11 KB
  webapi done           folder     c:\test1    9 KB
  webapi.zip            file       c:\test1    20 KB
  mvc.iso               file       c:\test4    5 KB
  </code></pre>
  
  <p>i got a sample code which look like for finding files but the below code may not find folder. so i am looking for a sample code which will find files and folders too. so guide me to solve my issue.</p>
  
  <p>the below sample code will find files but not sure does it find files by partial name. here is the code. i am not before dev environment. so could not test the below code.</p>
  
  <h2>find files code</h2>
  
  <pre><code>static void Main(string[] args)
      {
          string partialName = "webapi";
  
          DirectoryInfo hdDirectoryInWhichToSearch = new DirectoryInfo(@"c:\");
          FileInfo[] filesInDir = hdDirectoryInWhichToSearch.GetFiles("*" + partialName + "*.*");
  
          foreach (FileInfo foundFile in filesInDir)
          {
              string fullName = foundFile.FullName;
              Console.WriteLine(fullName);
          }
  
      }
  </code></pre>