Read Data Of A CSV File Without Saving It In C#

We can read the data of a CSV file without saving it onto a server. Given below are the steps:

  1. Create an aspx page and paste the following code into it.
    1. <asp:FileUpload ID="txt_Upload" runat="server" />  
    2. <asp:Button ID="btnsubmit" Text="Submit" runat="server" OnClick="btnsubmitclick"/>  
  2. In the cs file, paste the below method.
    1. protected void btnsubmitclick(object sender, EventArgs e)   
    2. {  
    3.     System.IO.StreamReader myReader = new System.IO.StreamReader(txt_Upload.PostedFile.InputStream);  
    4.     string output = myReader.ReadToEnd();  
    5.     Response.Write(output);