با سلام
من یک فایل متنی با حجم 500 مگابایت دارم که ابتدا میخوام خط به خط بخونمش ، بعد میخوام از محتوای فایلم فقط بخش یوزرنیم وآدرس آی پی رو بگیره داخل یک لیست یا آرایه دوبعدی بریزه ودر نهایت در دیتا گرید ویو نشون بده. ولی موقع اجرای برنامه، خطای out of memory میده. یک فایل با سایز کوچک که تست میکنم میده ولی فایل اصلی که حجیم هستش رو اجرا نمیکنه ، لطف میکنید کمک کنید.
public void ReadFile(string ConfigFile) { dataGridView1.ColumnCount = 2; dataGridView1.Columns[0].Name = "Name of server"; dataGridView1.Columns[0].HeaderText = "Name of server"; dataGridView1.Columns[0].DataPropertyName = "Name of server"; dataGridView1.Columns[1].HeaderText = "IP Address"; dataGridView1.Columns[1].Name = "IP Address"; dataGridView1.Columns[1].DataPropertyName = "IP Address"; using (StreamReader st = new StreamReader(ConfigFile)) { string lines = string.Empty; while ((lines = st.ReadLine()) != null) { int startIndex = lines.IndexOf('-'); var nextIndex = lines.IndexOf('(', startIndex); int length = nextIndex - startIndex - 1; string final = lines.Substring(startIndex + 1, length); var nextIpIndex = lines.IndexOf('(', startIndex); var next = lines.IndexOf(')', nextIpIndex); int len = next - nextIpIndex + 1; string fi = lines.Substring(nextIpIndex, len); names = new string[,] { { final, fi } }; if (!names[0, 1].Contains("(not logged in)")) { RemoveDuplicate(dataGridView1); dataGridView1.Rows.Add(new object[] { names[0, 0], names[0, 1] }); }
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)