title: the process cannot access the file because it is being used by another process in vb.net
body: <p>help me.. i'm new in visual basic....</p>
  
  <p>when i'm running the update it shows the error 
  The process cannot access the file 'C:\Documents and Settings\Macky\My Documents\Visual Studio 2008\Projects\Marcelo 2.2.3\Marcelo\bin\Debug\Students\MIC953867.jpg' because it is being used by another process.</p>
  
  <p>my code is this </p>
  
  <pre><code>Public Sub copingfile()
      If inFileName = Nothing Then
          studpic.Image = Nothing
      Else
          outFileName = inFileName
          pos = inFileName.LastIndexOf(".")
          If (pos &gt; 0) Then
              outFileName = outFileName.Substring(0, pos)
          End If
          outFileName += ".jpg"
          str = Application.StartupPath &amp; "\Students\"
          saveJPEGFile.FileName = str &amp; StudID.Text &amp; ".jpg" '&amp; outFileName
          fil1.Copy(inFileName, saveJPEGFile.FileName, True) 'the error shows here...
          outFileName = saveJPEGFile.FileName()
      End If
  
  End Sub
  </code></pre>
  
  <p>I can save new student information with picture.. but when it comes in updating the picture these codes didn't work......</p>