询问求MemoryMappedFile 类读取文件代码
有一个文件已经路径 c:\1.txt 需要将每行写入数组当中请问各位大侠如何实现 ? --------------------编程问答-------------------- string[] arr = System.IO.File.ReadAllLines("C:\\1.txt"); --------------------编程问答--------------------
--------------------编程问答-------------------- 问题可参看这个帖子
var mmf = MemoryMappedFile.CreateFromFile(@"c:\1.txt");
using (MemoryMappedViewStream MmvStream = mmf.CreateViewStream())
{
var reader = new BinaryReader(MmvStream);
var stream = reader.BaseStream;
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
stream.Seek(0, SeekOrigin.Begin);
//验证数组;
//FileStream fs = new FileStream(@"c:\2.txt", FileMode.Create);
//fs.Write(bytes,0, bytes.Length);
//fs.Flush();
//fs.Close();
}
http://bbs.csdn.net/topics/390654301
环境是被读取的文件较大>800M --------------------编程问答-------------------- 用stream实现分块读取
http://bbs.csdn.net/topics/350230269 --------------------编程问答-------------------- http://wenku.baidu.com/link?url=cTsBRvWC6E2M7jj_kihSfT5UQWRWpNALTT7YFx8olVgvS8zxST6qThOZs0JZdP5UrtihgdUSY9RsKzttMB0_ov5AxSREaSXGr6A53YkpPoW --------------------编程问答--------------------
目标文件很大超过1G
补充:.NET技术 , C#