Getting the actual file size

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to monitor the process of a file being copied, but I
cannot find a function that will return the actual file size, not the
total file size, as reported by fileinfo.length. Has anyone ever done
something like this before? I would rather do this instead of trying
to open the file exclusively.
 
I am trying to monitor the process of a file being copied, but I
cannot find a function that will return the actual file size, not the
total file size, as reported by fileinfo.length. Has anyone ever done
something like this before? I would rather do this instead of trying
to open the file exclusively.

The only reason why the "actual size" is larger than the "total file
size" is that the total file size reflects actually how much data is
in the file. The actual file size on disk is determined by the cluster
factor for the disk volume the file is stored on and is essentially
overhead you don't need to worry about when copying a file.
 
Thanks, but let me explain a little more as to what I am trying to do.

I monitor a directory for new files, but because the file sizes are so
larger that are getting copied, I do not want to process as soon as
they are created. Therefore, I want to create a small loop that goes
something like this:

Do until ActualFileSize = fileinfo.length
ActualFileSize = (function to check size)
thread.sleep(100)
Loop

So if a 60 mb file is copied, I want to monitor the progress. Actual
file size would grow as the file is being copied... 1k, 15k, 25k....
60mb complete. Does this make sense?
 
I think most people handle that by doing something like this:

Try
open the file
Catch
you can't open it, so it's not finished copying
sleep, or use a timer to wait a few seconds before trying again

Robin S.
 
Back
Top