471,594 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

During copying file , wanna read file Size

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?
Nov 28 '06 #1
2 3640

"somequestion" <so**********@gmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
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
Nov 28 '06 #2
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 <so**********@gmail.com
wrote:
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]
Nov 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Martin Ho | last post: by
1 post views Thread by chris.atlee | last post: by
9 posts views Thread by Adi | last post: by
3 posts views Thread by windstorm | last post: by
18 posts views Thread by mike3 | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.