c# - 更改 File.Copy 默认缓冲区大小。
问题描述
我正在寻找可能提高文件传输到网络驱动器的速度的方法。我目前正在使用标准的 File.Copy。有谁知道 File.Copy 的默认缓冲区大小以及是否可以更改它?
解决方案
鉴于File.Copy
使用 Window 的复制功能,您可以在源代码中看到:
internal const String KERNEL32 = "kernel32.dll";
[DllImport(KERNEL32, SetLastError=true, CharSet=CharSet.Auto, BestFitMapping=false)]
[ResourceExposure(ResourceScope.Machine)]
internal static extern bool CopyFile(...)
...
bool r = Win32Native.CopyFile(fullSourceFileName, fullDestFileName, !overwrite);
您可以做很多事情来优化它(事实上,什么都没有)。
推荐阅读
- java - 带有故障安全插件的空手道,未找到功能
- arrays - 当我删除数据表中的行时,函数中的行号会发生变化
- python - 如何在`pandas``Series`中进行“加权上采样”?
- firebase - Firebase 功能在进入睡眠状态之前保持活动状态多长时间?
- python-3.x - TCP客户端/服务器:客户端程序停止时服务器中断
- javascript - td 中的输入日期在单击时不显示日历。仅在 F4 按钮上
- html - Select2 和 Bootstrap:占位符之外的选定选项
- pandas - Pandas:删除重复出现的连续值
- google-cloud-pubsub - 通过 Spring Cloud Stream 发布到 Pub/Sub 的持久性保证
- java - 如果 null 可以分配给任何引用类型,为什么它不是 Java 中的对象?