//--------------------文件,复制--------------------------------------------- using System.IO /// <summary> /// 复制文件fileIn到文件fileOut /// </summary> public void copyfile(String fileIn, String fileOut) { FileStream FileIn = new FileStream(fileIn, FileMode.Open); //打开文件 FileStream FileOut = new FileStream(fileOut, FileMode.Create); //创建文件,有则覆盖 byte[] tmp = new byte[1024]; //缓存空间 int len = 0; while ((len = FileIn.Read(tmp, 0, tmp.Length)) > 0) //读取数据 { FileOut.Write(tmp, 0, len); //写到文件 FileOut.Flush(); } //关闭流 FileIn.Close(); FileOut.Close(); }
原文地址:http://blog.csdn.net/scimence/article/details/44828139