C#_File文件读取和写入
2015-12-19 23:54
381 查看
using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using LitJson; namespace CShapeTest { class Start { static void Main(string[] args) { // 文件读取类 // File.ReadAllLines类 //string[] strArray = File.ReadAllLines("Skill.json"); //foreach (var item in strArray) //{ // Console.WriteLine("File.ReadAllLines:" + item); //} // File.ReadAllText类 //string str = File.ReadAllText("Skill.json"); //Console.WriteLine("File.ReadAllText:" + str); // File.ReadAllBytes类 //byte[] bytes = File.ReadAllBytes("Skill.json"); //foreach (var item in bytes) //{ // Console.WriteLine(item); //} // 文件写入类 // File.WriteAllLines类 //File.WriteAllLines("Skill_1.json", new string[] {"cxm1", "cxm2", "cxm3"}); // File.WriteAllText类 //File.WriteAllText("Skill_1.json", "Hello world"); File.WriteAllBytes("Skill_1.json", new byte[] {0x01, 0x02, 0x03}); Console.ReadLine(); } } }
相关文章推荐
- c#调用COM组件
- 命令行小技巧:读取文件的不同方式
- IE:临时文件保存法
- 文件的读出 编辑 管理
- 文件遍历排序函数
- 在线用表单建立文件夹
- VB获取文件大小的方法
- 文件、目录,文本文件等多种操作类
- 处理驱动器和文件夹
- C#实现把指定数据写入串口
- C#动态创建button的方法
- 用vbs删除某些类型文件和磁盘空间报告的脚本
- 用批处理实现读取文本文件并实现超链接代码的输出[原创]_DOS/BAT_脚本之家
- C#中抽象方法与虚拟方法的区别
- c#中虚函数的相关使用方法
- C#使用加边法计算行列式的值
- C#实现多线程的同步方法实例分析
- ext读取两种结构的xml的代码
- C#中尾递归的使用、优化及编译器优化
- C#实现子窗体与父窗体通信方法实例总结