473,383 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How can I tell when my file is done copying?

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
3 3867
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
:-) 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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Patrick Useldinger | last post by:
Hi, I think I found a bug in the write method of file objects. It seems as if before writing each block, a check was done in order to verifiy that there is enough space left for the *whole*...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
10
by: JKop | last post by:
How should I go about file access in a portable C++ program? I've had a quick look through a reference and seen "fopen". Should I use that? Or has it been superseeded, sort of like "printf" and...
8
by: Jing Cheng | last post by:
Hi, I'm using ifstream reading data from a file, as following: ifstream finput("track.dat"); if(finput.fail()){ cerr << "Open input DATA file error!\n"; exit(-1);
2
by: Daniel Reber | last post by:
I have an application that is sending a file to a location on a network. I have a windows service that is monitoring that location for new files and then processing them. Sometimes the service...
8
by: John Smith | last post by:
Hi folks, I know how to place text into the user's clipboard: Clipboard.SetDataObject("My Copied Text"); but how do I place a file in there? So, if I have a file C:\test.txt, how can I place...
5
by: TB | last post by:
Hi All: This news group is proving to be great help on my path towards mastering ASP.NET thanks to all of you helpful souls out there. I am looking forward to the day when I can contribute...
18
by: mike3 | last post by:
Hi. I have an interesting problem. The C program presented below takes around 12 seconds to copy 128 MB of data on my machine. Yet I know the machine can go faster since a copying done at a...
0
by: Cameron Simpson | last post by:
On 09Jul2008 15:54, Ethan Furman <ethan@stoneleaf.uswrote: If you know that files appear in sequence (a single serial upload process, not multiple uploaders) you can augument this with a check...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.