日期:2014-05-17 浏览次数:20960 次
SafeFileHandle fr = CreateFile(soupath, GENERIC_READ, FILE_SHARE_READ, IntPtr.Zero, OPEN_EXISTING,FILE_FLAG_NO_BUFFERING, IntPtr.Zero); SafeFileHandle fw = CreateFile(destpath, GENERIC_WRITE, FILE_SHARE_READ, IntPtr.Zero, CREATE_ALWAYS,(FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH), IntPtr.Zero); int bufferSize =1024* 1024 * 32; FileStream fsr = new FileStream(fr, FileAccess.Read); FileStream fsw = new FileStream(fw, FileAccess.Write); BinaryReader br = new BinaryReader(fsr); BinaryWriter bw = new BinaryWriter(fsw); byte[] buffer = new byte[bufferSize]; Int64 len = fsr.Length; while (fsr.Position < fsr.Length) { int readCount = br.Read(buffer, 0, bufferSize); bw.Write(buffer, 0, readCount); } br.Close(); bw.Close();