I don’t know if the NewLine is causing any issues.
Maybe try this?
// write programming batch to server file
string tab = "\t";
string[] headerList = {"PartNum", "Filename", "Qty", "RawMtl", "Material", "Gauge", "JobNum", "Date"};
string header = "";
int numRecs = ttResults.Where(row => row.JobMtl_ProgrammingExported_c == true).Count();
if (numRecs > 0)
{
string fileName = @"\\E10-TCFDEV02\Radan\" + "RadanBatch_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + callContextClient.CurrentUserId + ".csv";
using(var sw = new System.IO.StreamWriter(fileName, false))
{
header = string.Join(tab, headerList);
sw.WriteLine(header); //WriteLine - header
var ttResultQuery = ttResults.Where(row => row.JobMtl_ProgrammingExported_c == true);
foreach (var ttResult in ttResultQuery)
{
string detail = "";
string[] lineList =
{ttResult.JobHead_PartNum,
ttResult.Part1_CutFileName_c,
ttResult.JobMtl_RequiredQty.ToString(),
ttResult.JobMtl_PartNum,
ttResult.Part_MaterialType_c,
ttResult.Part_Gauge_c.ToString(),
ttResult.JobHead_PartNum,
ttResult.JobOper_StartDate.Value.ToString("MM/dd/yyyy")};
detail = string.Join(tab,lineList);
sw.WriteLine(detail); //WriteLine - detail
}
// Removed sw.Write
sw.Close();
this.PublishInfoMessage("File Created: " + fileName, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}
}
else
{
this.PublishInfoMessage("No File Created.", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}