I'm creating a CSV file from a List<> like this:
public void ExportListToCSV()
{
StringWriter sw = new StringWriter();
sw.WriteLine("\"username\",firstname, lastname , email , course1 , course2 , course3 , course4 ");
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment;filename=OgrenciListesi.csv");
Response.ContentType = "text/csv";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1254");
Response.Charset = "windows-1254";
foreach (var line in Liste())
{
sw.WriteLine(string.Format("\"{0}\", {1} , {2} , {3} , {4} , {5} , {6} , {7} ",
line.KullaniciKodu,
line.Adi,
line.Soyadi,
line.Email,
line.Course1,
line.Course2,
line.Course3,
line.Course4
));
}
Response.Write(sw.ToString());
Response.End();
}
I want to send this CSV to server via FTP in same action (maybe in same method). How can i handle this CSV and upload to server via FTP in C#?