title: Delete a file which is used by another process in c#
body: <p>I am trying to delete one file which was used by certain another process of my Application.
  So its giving an Error that file is used by certain another process.</p>
  
  <pre><code>private void Form1_FormClosed(object sender, FormClosedEventArgs e)
  {
  
      DirectoryInfo NewDir = new DirectoryInfo(imagefolderpath1);
      FileInfo[] files = NewDir.GetFiles("*.jpg");
      foreach (var item in files)
      {
          string strFile = imagefolderpath1 + "\\" + item.ToString();
          if (File.Exists(strFile))
          {
  
              File.Delete(strFile);
          }
      }
  
  }
  </code></pre>
  
  <p>How should i solve this problem can you please help me????</p>