Reputation: 845
I got help from this site to write data from objects into tab delimited text files. It works great. The problem is it puts an extra blank line at the end of the file. Because of this a process which picks up the file fails. Please let me know if there is a way to block the code putting the extra line. The following is the code:
private void WriteFile<T>(string filePath, IEnumerable<T> objectlist, string userName, string password)
{
bool createHeader = false;
if (!File.Exists(filePath))
{
using (File.Create(filePath)) ;
createHeader = true;
}
string data = ToCsv<T>("\t", objectlist, createHeader);
var file = new StreamWriter(filePath, true);
file.WriteLine(data);
file.Close();
}
Upvotes: 0
Views: 1234