title: The process cannot access the file because it is being used by another process.c#
body: <p>I am trying to copy one image from one location to another location using File.Copy() function but it gives the process can not access exception,any one can please help on this bellow is the code block.I have attached screenshot for exception. </p>
  
  <pre><code>private void btnUpload_Click(object sender, EventArgs e)
  {  
      string SourcePath;
      string RootDrive;
      string DestPath;
      string fileName;
      fileName = "";
          try
          {
              OpenFileDialog ofd = new OpenFileDialog();
              ofd.Title = "Select Image to Upload";
              ofd.Filter = "Jpg|*.jpg|Jpge|*.jpge|Gif|*.gif";
              ofd.FileName = null;
              if (ofd.ShowDialog() != DialogResult.Cancel)
              {
                  fileName = ofd.FileName;
  
              }
              ofd.Dispose();
              DestPath = Directory.GetCurrentDirectory() + @"\Uploads\PropertyImages\";
                  string destFile = System.IO.Path.Combine(DestPath, fileName);
  
                  if (!System.IO.Directory.Exists(DestPath))
                  {
                      System.IO.Directory.CreateDirectory(DestPath);
                  }
                  System.IO.File.Copy(fileName, destFile, true);                                   
  
          }
          catch (Exception ae)
          {
              MessageBox.Show(ae.Message, "Upload Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
          }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/0qXMa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0qXMa.png" alt="enter image description here"></a></p>