Reputation: 1479
If you use one of FileStream
constructors you can specify buffer size in bytes but if you use File.OpenRead
you can't. What is the default value for buffer size which is used in the secondcase?
Upvotes: 2
Views: 1227
Reputation: 4928
Using Telerik JustDecompile to look at the code, it's 4096 B:
public static FileStream OpenRead(string path)
{
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
}
public FileStream(string path, FileMode mode, FileAccess access, FileShare share) : this(path, mode, access, share, 4096, FileOptions.None, Path.GetFileName(path), false)
{
}
Upvotes: 5
Reputation: 67898
It's 4096
as you can see from this constructor:
[SecuritySafeCritical]
public FileStream(string path, FileMode mode, FileAccess access, FileShare share)
: this(path, mode, access, share, 4096,
FileOptions.None, Path.GetFileName(path), false)
{
}
That's the constructor called by OpenRead
:
public static FileStream OpenRead(string path)
{
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
}
Upvotes: 5