Monitoring File Size

  • Thread starter Thread starter Curtis Kam
  • Start date Start date
C

Curtis Kam

Hi,

How can I monitor the file size of a file which is still copying? If I've
used FileInfo.Length, it'll return the final file size, not the intermediate
one. Thanks.

Regards,
Curtis Kam
 
FileInfo.Length will return the size of the file. The problem is that using
Explorer to copy a file (well, I guess it's probably the CopyFile API in
Windows) will cause the entire file to be allocated on disk and then the
data is transferred.

So, the result from FileInfo.Length depends on the application that copies
the file. You can see this by monitoring a file you're downloading using the
ftp command prompt tool which allocates the size as it is receiving data
FileInfo.Length would give you the true instant size.

Arild
 
Btw... if this is your own application that you want to monitor filecopying
in then you should look at the CopyFileEx API which provides callback
functionality to keep track of the progress.


Arild
 
Thanks,

I'm now using the FileStream object to read the file and write it byte by
byte, so I can know exactly the bytes that it's copied.

Regards,
Curtis Kam
 
Back
Top