By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

During copying file , wanna read file Size

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a

"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

P: n/a
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.