Home >

Using Memory Stream in .Net - Sample Code

4. March 2011

Memory stream is an excellent class to hold your content temporarily in our server memory. Following code snippet can be used as a starter of how to use it:

// write out new page in memory stream
MemoryStream stream = new MemoryStream(); 
StreamWriter writer =new StreamWriter(stream); 
writer.WriteLine("<html><body>");
writer.WriteLine("Hello, World");
writer.WriteLine("</body></html>");
writer.Flush();
 
// add new page to site
SPWeb site = SPContext.Current.Web;
site.Files.Add("hello.htm", stream);

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading