#region 实现多媒体文件的复制
string source = @"F:\123\source.avi";//源文件路径
string target = @"F:\123\test.avi";//复制后的文件路径 CopyFile(source, target);
Console.WriteLine("复制成功");
#endregion
Console.ReadKey(); public static void CopyFile(string source, string target)
{
//创建一个负责读取的流
using (FileStream fsRead = new FileStream(source, FileMode.Open, FileAccess.Read))
{
//创建一个负责写入的流
using (FileStream fsWrite = new FileStream(target, FileMode.OpenOrCreate, FileAccess.Write))
{
byte[] buffer = new byte[1024 * 1024 * 5]; //因为文件可能比较大所以在读取的时候应该用循坏去读取
while (true)
{
//返回本次实际读取到的字节数
int r = fsRead.Read(buffer, 0, buffer.Length); if (r == 0)
{
break;
}
fsWrite.Write(buffer, 0, r);//写入
} }
}
//使用StreamReader读取文本文件
using (StreamReader sr = new StreamReader(@"F:\123.txt", Encoding.Default))
{
while (!sr.EndOfStream)
{
Console.WriteLine(sr.ReadLine());
}
} //使用StreamWrite写入文本文件
using (StreamWriter sw = new StreamWriter(@"F:\123.txt"))
{
sw.Write("写入内容");
}

最新文章

  1. 【初探Spring】------Spring IOC(三):初始化过程---Resource定位
  2. .net mvc中json的时间格式
  3. iOS-推送通知详解
  4. selenium-webdriver(python) (十四) -- webdriver原理
  5. Python基本数据类型之list
  6. Oracle创建表格报ORA-00906:缺失左括号错误解决办法
  7. 【leetcode❤python】299. Bulls and Cows
  8. iOS开发-表视图的使用
  9. (转) 如何在JavaScript与ActiveX之间传递数据1
  10. ECshop网店系统百万级商品量性能优化-加快首页访问速度
  11. Fetch的使用
  12. openerp 产品图片的批量写入
  13. WCF入门教程系列六
  14. Scala学习文档-样本类与模式匹配(match,case,Option)
  15. Object 类
  16. windowns10安装httpd
  17. 解决iPhone Safari 兼容性CSS背景显示不全问题
  18. python修炼第四天
  19. Leetcode 11.盛最多水的容器 By Python
  20. hibernate中的addEntity setResultTransformer的比较

热门文章

  1. Browser对象之Window对象
  2. Spring Cloud面试题
  3. child_process
  4. JavaEE之会话技术Cookie&Session
  5. ArcSDE10.2.2使用SQL操作ST_Geometry时报ORA-28579或ORA-20006错误
  6. Mac下终端自动补全功能
  7. Charles下载和使用
  8. shell编程报错:“syntax error near unexpected token `”
  9. jdbc 块提取方式
  10. Centos7开放端口