File.Move copies file instead

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
 
Z

zdrakec

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top