During copying file , wanna read file Size

  • Thread starter Thread starter somequestion
  • Start date Start date
S

somequestion

During copying file , wanna read file Size like this

string CheckFileSize(string fileName)
{
if( fileName == null ) return;
FileInfo fi = new FileInfo(fileName);
return fi.Length.ToString();
}

but it shows total file size...
i just wanna read changing of file Size....
how can i get this?
 
Hi,

You need to do your own copying using Streams. For every chunk of data
written to the new file, update a byte counter that you can read when
checking file size.

The article in this link describes how to copy by transferring a byte from
one file to another, although you may want to read and write larger chunks
(multiples of 1024) using Stream.Read/Write.

http://www.java2s.com/Code/CSharp/File-Stream/Copyafile.htm
 
somequestion said:
During copying file , wanna read file Size like this

string CheckFileSize(string fileName)
{
if( fileName == null ) return;
FileInfo fi = new FileInfo(fileName);
return fi.Length.ToString();
}

but it shows total file size...
i just wanna read changing of file Size....
how can i get this?

Wel, you know the length you copied,
why not simply subtract that length?

Adrian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top