C
Carmelo
Hi there,
I'm a newbie on C# and I was trying just to open a file, read it
byte-a-byte and close controlling the length of this operation. Doing
that with a 500Kb file I get a duration of about 3,5 seconds and doing
it on a 8Mb file i get 55 seconds!!. Is that ok??, or is something
wrong...I guess that is too much time, I expect having a lower times,
but don't know. See code:
DateTime start = DateTime.Now;
string fileName = args[0];
FileInfo file = new FileInfo( fileName );
Stream buff = new BufferedStream( new FileStream( file.FullName,
FileMode.Open,
FileAccess.Read ));
BinaryReader ins = new BinaryReader(buff);
while ( (ins.BaseStream.Position) < ins.BaseStream.Length )
{
ins.ReadByte();
}
buff.Close();
TimeSpan total = DateTime.Now.Subtract( start );
Console.WriteLine( "time length=
"+total.TotalMilliseconds.ToString());
I'm a newbie on C# and I was trying just to open a file, read it
byte-a-byte and close controlling the length of this operation. Doing
that with a 500Kb file I get a duration of about 3,5 seconds and doing
it on a 8Mb file i get 55 seconds!!. Is that ok??, or is something
wrong...I guess that is too much time, I expect having a lower times,
but don't know. See code:
DateTime start = DateTime.Now;
string fileName = args[0];
FileInfo file = new FileInfo( fileName );
Stream buff = new BufferedStream( new FileStream( file.FullName,
FileMode.Open,
FileAccess.Read ));
BinaryReader ins = new BinaryReader(buff);
while ( (ins.BaseStream.Position) < ins.BaseStream.Length )
{
ins.ReadByte();
}
buff.Close();
TimeSpan total = DateTime.Now.Subtract( start );
Console.WriteLine( "time length=
"+total.TotalMilliseconds.ToString());