(编辑:请注意问题已更改; byte[]最初未提及;请参阅修订版1)
好吧,File.Copy跳到脑海; 但否则这听起来像一个Stream场景:
using (Stream source = File.OpenRead(inPath))
using (Stream dest = File.Create(outPath)) {
byte[] buffer = new byte[2048]; // pick size
int bytesRead;
while((bytesRead = source.Read(buffer, 0, buffer.Length)) > 0) {
dest.Write(buffer, 0, bytesRead);
}
}
Run Code Online (Sandbox Code Playgroud)
byte[] data = File.ReadAllBytes(path1);
File.WriteAllBytes(path2, data);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9866 次 |
| 最近记录: |