1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.IO; 6 7 namespace PrintLableCode 8 { 9 class FileHelper10 {11 ListreadList = null;12 /// 13 /// 读取文件14 /// 15 /// 16 ///17 public List readFiles(string path)18 {19 StreamReader reader = new StreamReader(path,Encoding.Default);20 string lines;21 while((lines=reader.ReadLine())!=null)22 {23 readList.Add(lines.ToString());24 }25 return readList;26 }27 /// 28 /// 文件写入29 /// 30 /// 31 /// 32 public void writeFiles(string path,string str)33 {34 FileStream fs = new FileStream(path, FileMode.Append);35 StreamWriter sw = new StreamWriter(fs);36 sw.WriteLine(str);37 sw.Flush();38 sw.Close();39 }40 }41 }