<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Prad.NET</title>
	<atom:link href="http://pradeepgj.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://pradeepgj.wordpress.com</link>
	<description>OK!!! I am not a nerd !!!</description>
	<lastBuildDate>Thu, 06 Sep 2007 19:56:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='pradeepgj.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Prad.NET</title>
		<link>http://pradeepgj.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://pradeepgj.wordpress.com/osd.xml" title="Prad.NET" />
	<atom:link rel='hub' href='http://pradeepgj.wordpress.com/?pushpress=hub'/>
		<item>
		<title>ASP.NET &#8211; uploading and reading a comma seperated value (.CSV) file into stream</title>
		<link>http://pradeepgj.wordpress.com/2007/09/06/aspnet-uploading-and-reading-a-comma-seperated-value-csv-file-into-stream/</link>
		<comments>http://pradeepgj.wordpress.com/2007/09/06/aspnet-uploading-and-reading-a-comma-seperated-value-csv-file-into-stream/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 19:21:32 +0000</pubDate>
		<dc:creator>Pradeep Jayaraman</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://pradeepgj.wordpress.com/2007/09/06/aspnet-uploading-and-reading-a-comma-seperated-value-csv-file-into-stream/</guid>
		<description><![CDATA[This post explains how to upload a csv file into a stream on the server without uploading the file into a physical server location. I have used a asp.net file upload control. This control exposes some properties which can be used to our advantage. 1. Content type &#8211; This returns the content type of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pradeepgj.wordpress.com&amp;blog=1648913&amp;post=7&amp;subd=pradeepgj&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This post explains how to upload a csv file into a stream on the server without uploading the file into a physical server location.</p>
<p>I have used a asp.net file upload control. This control exposes some properties which can be used to our advantage.</p>
<p>1. Content type &#8211; This returns the content type of the uploaded file. You can use this to make sure the content being uploaded is really an excel type file.</p>
<p>2. InputStream &#8211; This returns the stream object into which the contents of the file are loaded. This stream can be loded into a stream reader and you have the contents line by line.<br />
 </p>
<pre class="brush: vb;">
        'Code to upload csv file intp stream reader
        Dim streamReader As System.IO.StreamReader
        Dim fileUpload As System.Web.UI.WebControls.FileUpload = Me.FileUpload 'This control has to be added to the web form
        Dim filePath As String = System.IO.Path.GetFileName(fileUpload.PostedFile.FileName)
        If Not filePath.Trim().Equals(String.Empty) Then
            If fileUpload.PostedFile.ContentType.Equals("application/vnd.ms-excel") Then
                If (fileUpload.PostedFile.InputStream.Length &gt; 0) Then
                    If (fileUpload.PostedFile.FileName.ToLower().EndsWith(".csv")) Then
                        ' Read and display the lines from the file until the end of the file is reached.
                        streamReader = New System.IO.StreamReader(fileUpload.PostedFile.InputStream)
                        streamReader.Close()
                    End If
                End If
            End If
        End If
        '----Code to read the stream reader line by line
        While Not streamReader.EndOfStream
            Dim strEmployeeIncreases As String = streamReader.ReadLine()
        End While
        'Make sure you close the stream reader after reading all the data using the following line of code to free up system
        streamReader.Close()
        'Also one more tip: If you want to skip to the top of the stream reader at any point of time, you can use
        streamReader.BaseStream.Seek(0, System.IO.SeekOrigin.Begin)
</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pradeepgj.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pradeepgj.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pradeepgj.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pradeepgj.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pradeepgj.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pradeepgj.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pradeepgj.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pradeepgj.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pradeepgj.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pradeepgj.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pradeepgj.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pradeepgj.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pradeepgj.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pradeepgj.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pradeepgj.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pradeepgj.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=pradeepgj.wordpress.com&amp;blog=1648913&amp;post=7&amp;subd=pradeepgj&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://pradeepgj.wordpress.com/2007/09/06/aspnet-uploading-and-reading-a-comma-seperated-value-csv-file-into-stream/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/39f9a505903c4f82280a21df3225cb2c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Prad</media:title>
		</media:content>
	</item>
	</channel>
</rss>
