By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,826 Members | 1,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,826 IT Pros & Developers. It's quick & easy.

How can I tell when my file is done copying?

P: n/a
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?

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies

P: n/a
if File.Copy doesn't throw, then you can fairly safely assume it was copied.

"Terry Olsen" <to******@hotmail.com> wrote in message
news:uf**************@TK2MSFTNGP12.phx.gbl...
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?

*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #2

P: n/a
:-) 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]

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:dc*******************@news.demon.co.uk...
if File.Copy doesn't throw, then you can fairly safely assume it was
copied.

"Terry Olsen" <to******@hotmail.com> wrote in message
news:uf**************@TK2MSFTNGP12.phx.gbl...
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?

*** Sent via Developersdex http://www.developersdex.com ***


Nov 21 '05 #3

P: n/a
"Terry Olsen" <to******@hotmail.com> wrote in message
news:uf**************@TK2MSFTNGP12.phx.gbl...
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.
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.