c#完整读写文件
来源:互联网 发布:二手车统一发票软件 编辑:程序博客网 时间:2024/05/19 18:42
FileStream oldfile = new FileStream(@"??", FileMode.Open, FileAccess.Read, FileShare.Read); BufferedStream oldbuff = new BufferedStream(oldfile); FileStream newfile = new FileStream(@"??", FileMode.Create, FileAccess.ReadWrite, FileShare.Read); BufferedStream newbuff = new BufferedStream(newfile); int len = 1024;//每次1024字节 byte[] data = new byte[len]; int block = 0; while ((block = oldbuff.Read(data, 0, len)) > 0) { newbuff.Write(data, 0, block); } Console.WriteLine(newbuff.Length); newbuff.Flush(); newfile.Flush(); newbuff.Close(); newfile.Close(); oldbuff.Close(); oldfile.Close();
网上有些简化写法比较误导人,只有如上述才能够把所有的数据全部写入新文件里,不多不少。
0 0
- c#完整读写文件
- 用C#读写ini配置文件完整范例
- C#注册表读写完整操作类
- C#读写INI文件
- C#读写INI文件
- C#读写INI文件
- C#读写INI文件
- c#读写xml文件
- c#读写xml文件
- c#读写xml文件
- C#读写文件
- C# 文件读写
- C#读写xml文件
- c#读写ini文件
- C#读写INI文件
- c#读写xml文件
- C#读写xml文件
- c# 读写xml文件
- java webservice(二)
- 菜鸟进化史
- C# XML序列化实例学习:XmlSerializer
- Android工程中的armeabi与armeabi-v7a
- vs2010无法打开项目文件,此安装不支持该项目类型解决方法
- c#完整读写文件
- Best localrc for devstack
- 在Coxoa和Objextive-C中使用Swift(1)Basic Setup
- [译]class android.media.MediaPlayer
- ubuntu安装ftp服务器(一般配置)
- 如何利用git和github参与开源项目
- Aspera Server端设置
- 如何用 纯C++(ndk)开发安卓应用
- iOS exit函数深入浅出