Check file is finished writing to disk

I use file.exist() and it says file exists, but it is not finished being written to disk because when i loadImage() i get errors that say the file is not all there.

Is there any other way to check when a file is finished being written from , in this case a call to and external program that converts a .bmp from a scanner to a .png for Processing to use?

I can make it work by adding a delay(500) after the file.exists() is true, but it is true before the file is completely written to the hard drive.

The problem with that is that the delay is different depending on the size of the image scanned so the delay solution is not universal to all size scanned images.

I searched the forum and online, the only solution i find is the file.exists() one, which does not work.
It may be true when the name is written to disk and it finds the file name in the directory, but it is
not finished writing the whole file to disk.

By the way , i tryed checking file.length() after file.exists() is true and the number doesn’t make sense for the number of bytes in the file and it is not always the same.

I tryed putting file.length() after the delay , when i am sure the entire file IS written and it sy\till gives me different numbers instead of the same value for the same size file.

any suggestions?

Maybe try out: hint(DISABLE_ASYNC_SAVEFRAME); :thinking:

1 Like