How can I tell when my file is done copying?

T

Terry Olsen

Using the following code to copy a file from a local pc to a remote
server across a 128K line:

File.Copy(src, dst, True)

If File.LastWriteDate(src) = File.LastWriteDate(dst) Then
Msgbox("Upload Verified.")
Else
Msgbox("Upload Failed.")
End If

It always comes back failed. But if I wait a few moments and check it
again, it'll come back Verified.

I guess the File.Copy is exiting before the copy is complete? So how
would I be able to verify the copy has fully completed before checking
the LastWriteDate?
 
M

m.posseth

:) in addition to Robin

try
File.Copy(src, dst, True)
Msgbox("Upload Verified.")
catch ex as exception
Msgbox("Upload Failed.")
end try

Michel Posseth [MCP]
 
P

Phill. W

Terry Olsen said:
If File.LastWriteDate(src) = File.LastWriteDate(dst) Then

But if I wait a few moments and check it again

If this using any third party connectivity stuff, e.g. SAMBA to a Unix
box? Could the file information be being cached?

To be honest, though, so long as .Copy doesn't throw an Exception,
you can pretty much assume that the file's been correctly delivered.

HTH,
Phill W.
 

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

Top