File.Move copies file instead

  • Thread starter Thread starter brian.gabriel
  • Start date Start date
B

brian.gabriel

I have a ASP.Net application written in VB.Net, I have a file import
function that imports a file then moves the file to an archive.

The problem is that the File.Move statement copies the file, but
original file is not removed even though the file now shows up in the
archive.

There are no errors being reported, we log errors to the event log via
the exception handling application block. There are no errors in the
system, app. or security logs. Everything else happen normally.

Here is the offending snippet:

Private Sub MoveFiles(ByVal sFrom As String, ByVal sTo As String)
If File.Exists(sFrom) Then
File.Move(sFrom, sTo)
End If
End Sub

Thanks,

Brian
 
Well, you could add, after File.Move(sFrom,sTo):

If File.Exists(sTo) 'make sure the file actually got there!
If File.Exists(sFrom) Then Kill(sFrom) 'if it did move after all,
just killing it will throw an exception
End If

Cheers,
zdrakec
 
Back
Top