Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. exception of type 'system.outofmemoryexception' was thrown

exception of type 'system.outofmemoryexception' was thrown

Scheduled Pinned Locked Moved ASP.NET
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    ptvce
    wrote on last edited by
    #1

    Im writing this code for display data in excel, try { string Path = "G:\\AjanceReport\\TotalReportExcelfile_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Month.ToString() + ".xls"; FileInfo FI = new FileInfo(Path); StringWriter stringWriter = new StringWriter(); HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWriter); DataGrid DataGrd = new DataGrid(); DataGrd.DataSource = dsGrid; DataGrd.DataBind(); DataGrd.RenderControl(htmlWrite); string directory = Path.Substring(0, Path.LastIndexOf("\\"));// GetDirectory(Path); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } System.IO.StreamWriter vw = new System.IO.StreamWriter(Path, true); stringWriter.ToString().Normalize(); vw.Write(stringWriter.ToString()); vw.Flush(); vw.Close(); WriteAttachment(FI.Name, "application/vnd.ms-excel", stringWriter.ToString()); } catch (Exception ex) { //throw new Exception(ex.Message); } but i see this error : exception of type 'system.outofmemoryexception' was thrown any body know what can i do???

    A 1 Reply Last reply
    0
    • P ptvce

      Im writing this code for display data in excel, try { string Path = "G:\\AjanceReport\\TotalReportExcelfile_" + DateTime.Now.Day.ToString() + "_" + DateTime.Now.Month.ToString() + ".xls"; FileInfo FI = new FileInfo(Path); StringWriter stringWriter = new StringWriter(); HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWriter); DataGrid DataGrd = new DataGrid(); DataGrd.DataSource = dsGrid; DataGrd.DataBind(); DataGrd.RenderControl(htmlWrite); string directory = Path.Substring(0, Path.LastIndexOf("\\"));// GetDirectory(Path); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } System.IO.StreamWriter vw = new System.IO.StreamWriter(Path, true); stringWriter.ToString().Normalize(); vw.Write(stringWriter.ToString()); vw.Flush(); vw.Close(); WriteAttachment(FI.Name, "application/vnd.ms-excel", stringWriter.ToString()); } catch (Exception ex) { //throw new Exception(ex.Message); } but i see this error : exception of type 'system.outofmemoryexception' was thrown any body know what can i do???

      A Offline
      A Offline
      Anurag Sinha V
      wrote on last edited by
      #2

      Hey, How many records do you have in your excel file? Are they too much, I mean System.OutOfMemoryException hits when there is not much memory left for the application? have a look at your excel and see whether you can optimize it.. -Anurag

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups