您的位置:首页 > 编程语言 > C#

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# 文件 读取 写入