如果您使用其中一个FileStream构造函数,您可以指定缓冲区大小(以字节为单位),但如果您使用则File.OpenRead不能。第二种情况下使用的缓冲区大小的默认值是多少?
4096正如您从这个构造函数中看到的那样:
[SecuritySafeCritical]
public FileStream(string path, FileMode mode, FileAccess access, FileShare share)
: this(path, mode, access, share, 4096,
FileOptions.None, Path.GetFileName(path), false)
{
}
Run Code Online (Sandbox Code Playgroud)
这是调用的构造函数OpenRead:
public static FileStream OpenRead(string path)
{
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
}
Run Code Online (Sandbox Code Playgroud)
使用Telerik JustDecompile查看代码,是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)
{
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1113 次 |
| 最近记录: |