读取大文件时抛出错误

时间:2017-01-03 07:01:30

标签: c# .net

我需要根据文本行的文本顺序排序,当我读取大约100MB的文件大小时,一切正常,但是当我读取文件并且其大小约为300MB时,就会发生内存错误。

功能详情如下:

  <form method="POST">
            Email id:<input type="text" name="username"><br>
            Password:<input type="text" name="password"><br>
            First Name:<input type="text" name="First_Name"><br>
            Second Name<input type="text" name="Second_Name"><br>
            <input type="submit" name="save">
        </form>

//Create connection $db = mysqli_connect($servername, $username, $password, $db_name); //check connection if ($db) { echo"Conneceted successfully"; } if (isset($_POST['save'])) { $username = $_POST['username']; $password = $_POST['password']; $fname = $_POST['First_Name']; $sname = $_POST['Second_Name']; $query = "insert into accounts(First_Name,Second_Name,email_id,password) VALUES('" . $fname . "','" . $sname . "','" . $username . "','" . $password ."'"; $insert = mysqli_query($db, $query); } if($insert){ echo "Record Inserted"; } else { echo "Error"; } ?> 已提供给var filePath = @"D:\junk\test.txt"; var fileSize = new FileInfo(filePath).Length; var viewSize = fileSize List<string> rowArray = new List<string>(); using (var mm = MemoryMappedFile.CreateFromFile(filePath, FileMode.Open, null, 0, MemoryMappedFileAccess.Read)) using (var stream = mm.CreateViewStream(0, viewSize, MemoryMappedFileAccess.Read)) using (var reader = new StreamReader(stream, Encoding.UTF8)) { rowArray.Add(reader.ReadLine()); } 数据源,rowArray使用虚拟模式

我尝试过:

我使用第三方软件读取文件,无论是100MB大小还是300MB大小,一切正常

0 个答案:

没有答案