10-25-2021 10:54 PM
Hi all,
I have a VI where I essentially copy 7-8 multi GB files (~5GB) from one location to another on my hard drive. However, I've noticed that sometimes the file will not fully transfer. Sometimes one or two files are completely empty, sometimes they only get a partial copy the data. My guess is that the copy command does not finish copying before moving on to the next file and they end up colliding. But, I don't know how to stop the behaviour as I would prefer to get it right on the first try and not have to query the data size and then re-execute the copy until it has finished copying all of the files (or try and figure out how long to wait since the files size may change based on say measurement time). Since the code is kind of short, the psuedo code equivalent of my statement is
for file in files
1. copy file from path 1 to path 2
2. wait 10ms
end
where 1. and 2. indicate sequence of events.
Thanks for any help that you can give.
10-25-2021 11:18 PM
It would help to see some code and more details (e.g. OS, amount of RAM, write cache policy, etc.)
10-26-2021 06:18 AM
@ControlFreq wrote:
But, I don't know how to stop the behaviour as I would prefer to get it right on the first try and not have to query the data size and then re-execute the copy until it has finished copying all of the files (or try and figure out how long to wait since the files size may change based on say measurement time).
You wouldn't need to reexecute the copy, just the checking of the file size until it was correct. Of course, this is assuming the file size is not set by the copy before the data starts to be written.
10-26-2021 06:25 AM
@crossrulz wrote:
@ControlFreq wrote:
But, I don't know how to stop the behaviour as I would prefer to get it right on the first try and not have to query the data size and then re-execute the copy until it has finished copying all of the files (or try and figure out how long to wait since the files size may change based on say measurement time).
You wouldn't need to reexecute the copy, just the checking of the file size until it was correct. Of course, this is assuming the file size is not set by the copy before the data starts to be written.
I'd (also) check the permissions (Get Permissions), to see if it changes.
10-26-2021 09:47 AM - edited 10-26-2021 01:47 PM
We also need to know how you are checking the file size. If this is windows, the explorer window might not correctly update until you refresh the page, for example.
I really doubt that LabVIEW is doing anything special. Most likely it just hands it over to a windows function and returns, while the actual copying can take a very long time for such large files, especially since they probably exceed the disk cache size. What kind of drives are these (source and destination, HD, SSD, USB stick (or fake USB stick/ SD card that pretends to be larger than it really is!), network, etc.).
How long does such a file copy take when you do it manually?
Did you check the drives for errors?
Are these disk location monitored by other software (OneDrive, Google Drive, etc.)
10-26-2021 01:13 PM
Forgot to speculate about Virus tools getting in the way as well.
10-26-2021 06:08 PM
@ControlFreq wrote:
Hi all,
I have a VI where I essentially copy 7-8 multi GB files (~5GB) from one location to another on my hard drive. However, I've noticed that sometimes the file will not fully transfer. Sometimes one or two files are completely empty, sometimes they only get a partial copy the data. My guess is that the copy command does not finish copying before moving on to the next file and they end up colliding. But, I don't know how to stop the behaviour as I would prefer to get it right on the first try and not have to query the data size and then re-execute the copy until it has finished copying all of the files (or try and figure out how long to wait since the files size may change based on say measurement time). Since the code is kind of short, the psuedo code equivalent of my statement is
for file in files
1. copy file from path 1 to path 2
2. wait 10ms
end
where 1. and 2. indicate sequence of events.
Thanks for any help that you can give.
What does "essentially copy" mean? It obviously doesn't mean "just copy".
10-28-2021 03:10 AM - edited 10-28-2021 03:47 AM
If this remains unsolved, you could do the copy "manually". In a for loop, read a few (e.g. 4096) bytes from source, write them to destination file. After you're done, make sure you flush the destination file.
This would be a last resort, it's definitely not desirable. It's more complex, uses more memory and CPU, but it will be more deterministic.
Another option is to try how a .NET copy works. It might act the same, or you might have options. Simply copying a file is probably just one static method. There might be events that are send when the copy is done.