Monitoring File Size

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Curtis Kam

    Monitoring File Size

    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


  • Arild Bakken

    #2
    Re: Monitoring File Size

    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

    "Curtis Kam" <lun1008@hongko ng.com> wrote in message
    news:O$lhve7nEH A.644@tk2msftng p13.phx.gbl...[color=blue]
    > 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
    >
    >[/color]


    Comment

    • Arild Bakken

      #3
      Re: Monitoring File Size

      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

      "Arild Bakken" <arildb_@hotmai l.com> wrote in message
      news:%23R1cIl8n EHA.4032@TK2MSF TNGP15.phx.gbl. ..[color=blue]
      > 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
      >
      > "Curtis Kam" <lun1008@hongko ng.com> wrote in message
      > news:O$lhve7nEH A.644@tk2msftng p13.phx.gbl...[color=green]
      >> 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
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Curtis Kam

        #4
        Re: Monitoring File Size

        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

        "Arild Bakken" <arildb_@hotmai l.com> wrote in message
        news:eyGI%23n8n EHA.3968@TK2MSF TNGP11.phx.gbl. ..[color=blue]
        > Btw... if this is your own application that you want to monitor[/color]
        filecopying[color=blue]
        > in then you should look at the CopyFileEx API which provides callback
        > functionality to keep track of the progress.
        >
        >
        > Arild
        >
        > "Arild Bakken" <arildb_@hotmai l.com> wrote in message
        > news:%23R1cIl8n EHA.4032@TK2MSF TNGP15.phx.gbl. ..[color=green]
        > > 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[/color][/color]
        copies[color=blue][color=green]
        > > 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
        > >
        > > "Curtis Kam" <lun1008@hongko ng.com> wrote in message
        > > news:O$lhve7nEH A.644@tk2msftng p13.phx.gbl...[color=darkred]
        > >> Hi,
        > >>
        > >> How can I monitor the file size of a file which is still copying? If[/color][/color][/color]
        I've[color=blue][color=green][color=darkred]
        > >> used FileInfo.Length , it'll return the final file size, not the
        > >> intermediate
        > >> one. Thanks.
        > >>
        > >> Regards,
        > >> Curtis Kam
        > >>
        > >>[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...