We can read the data of a CSV file without saving it onto a server. Given below are the steps:
- Create an aspx page and paste the following code into it.
- <asp:FileUpload ID="txt_Upload" runat="server" />
- <asp:Button ID="btnsubmit" Text="Submit" runat="server" OnClick="btnsubmitclick"/>
- In the cs file, paste the below method.
- protected void btnsubmitclick(object sender, EventArgs e)
- {
- System.IO.StreamReader myReader = new System.IO.StreamReader(txt_Upload.PostedFile.InputStream);
- string output = myReader.ReadToEnd();
- Response.Write(output);
- }