<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>.toString() &#187; vb</title>
	<atom:link href="http://www.dottostring.com/tag/vb/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dottostring.com</link>
	<description>Programming is our passion</description>
	<lastBuildDate>Sun, 04 Oct 2009 15:57:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Writing a MemoryStream to Browser</title>
		<link>http://www.dottostring.com/2008/12/writing-a-memorystream-to-browser/</link>
		<comments>http://www.dottostring.com/2008/12/writing-a-memorystream-to-browser/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 12:30:44 +0000</pubDate>
		<dc:creator>ahsan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[memorystream]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[response]]></category>
		<category><![CDATA[vb]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=143</guid>
		<description><![CDATA[The following piece of code can be used to write a memory stream to any browser. In my case its a pdf file so i am using  &#8220;HttpContext.Current.Response.ContentType = &#8220;application/pdf&#8221; &#8221;  only this line is changed when there is amy other type of file in memory stream:

Public Sub ViewMS(ByVal fs As MemoryStream)
	Dim buffer(fs.Length) [...]]]></description>
			<content:encoded><![CDATA[<p>The following piece of code can be used to write a memory stream to any browser. In my case its a pdf file so i am using  &#8220;HttpContext.Current.Response.ContentType = &#8220;application/pdf&#8221; &#8221;  only this line is changed when there is amy other type of file in memory stream:</p>
<pre name="code" class="vb">
Public Sub ViewMS(ByVal fs As MemoryStream)
	Dim buffer(fs.Length) As Byte
	fs.Position = 0
	fs.Read(buffer, 0, fs.Length)
	HttpContext.Current.Response.Buffer = False
	HttpContext.Current.Response.ContentType = "application/pdf"  'In my case its a pdf
	HttpContext.Current.Response.OutputStream.Write(fs.GetBuffer(), 0, fs.Length)
	HttpContext.Current.Response.Flush()
	HttpContext.Current.Response.End()
	fs.Dispose()
	fs.Close()
End Sub
</pre>
<p>Hope this may help anyone</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2008%2F12%2Fwriting-a-memorystream-to-browser%2F';
  addthis_title  = 'Writing+a+MemoryStream+to+Browser';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2008/12/writing-a-memorystream-to-browser/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
