You must Sign In to post a response.
  • Category: .NET

    Read data from txt file and write to CSV file.

    I have to read data from txt file and write it to csv file in c#
  • #762420
    Hi

    Ashok

    Try this code working for Read Text File and Export csv File.

    This is working for me.



    string path = @"D:\temp\New.txt";
    string readText = File.ReadAllText(path);


    Response.Clear();
    Response.Buffer = true;
    Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.csv");
    Response.Charset = "";
    Response.ContentType = "application/text";
    StringBuilder sb = new StringBuilder();
    sb.Append(readText);
    Response.Output.Write(sb.ToString());
    Response.Flush();
    Response.End();


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


Sign In to post your comments