Connecting Tech Pros Worldwide Forums | Help | Site Map

During copying file , wanna read file Size

somequestion
Guest
 
Posts: n/a
#1: Nov 28 '06
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?

> Adrian
Guest
 
Posts: n/a
#2: Nov 28 '06

re: During copying file , wanna read file Size



"somequestion" <somequestion@gmail.comwrote in message
news:%23d15eNqEHHA.4256@TK2MSFTNGP04.phx.gbl...
Quote:
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


Morten Wennevik
Guest
 
Posts: n/a
#3: Nov 28 '06

re: During copying file , wanna read file Size


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/Fi.../Copyafile.htm


On Tue, 28 Nov 2006 05:12:00 +0100, somequestion <somequestion@gmail.com
wrote:
Quote:
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?


--
Happy Coding!
Morten Wennevik [C# MVP]
Closed Thread