Visual Studio 2012 Express对读取大文件有限制吗?

本文关键字:文件 有限制 读取 Studio 2012 Express Visual | 更新日期: 2023-09-27 17:51:12

下面是我读取文本文件的代码,该文件大于1GB,并且是管道分隔的:

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string strFilePath = @"C:'Users'Me'Desktop'123.txt";
        private void button1_Click(object sender, EventArgs e)
        {
            var arrRawData = File.ReadLines(strFilePath).Select(line => line.Split('|')).ToArray();
        }
    }
}

当我点击按钮时,我得到这个错误:

"系统。OutOfMemoryException' occurred in mscorlib.dll"

我有16GB的RAM…我做错了什么?

Visual Studio 2012 Express对读取大文件有限制吗?

您的程序在32位模式下运行。这将永远不允许读取超过650兆字节的数据,这大约是地址空间中可用的最大大小的洞。

Project + Properties, Build选项卡,取消"Prefer 32-bit"选项。

请注意,在几乎所有解析文件数据的应用程序中,使用这么多内存仍然是不必要的。使用StreamReader类每次读取一行。

visual studio没有限制。你可能有16G,但你不能把它全部用在你的程序中。尝试使用流或不同时读取整个文件,而是逐行读取…

运行程序时出现错误:"尝试运行项目时出现错误:无法启动程序。Windows Web服务框架中出现无法识别的错误。

解决方案是关闭防火墙。防火墙入手:

Event: Traffic
IP Address/User: 0000:0000:0000:0000:0000:0000:0000:0001
Description: Microsoft Visual Studio 2012 (devenv.exe)
Path: C:'Program Files (x86)'Microsoft Visual Studio 11.0'Common7'IDE'devenv.exe
Message: Blocked Outgoing TCP - Source 0000:0000:0000:0000:0000:0000:0000:0001 :  (12276)  Destination 0000:0000:0000:0000:0000:0000:0000:0001 :  (12275)