Hi @Peter_1985 ,
You can add an additional check to ensure that the last line contains the correct CR LF (\r\n
) terminator. If it’s missing, append the necessary CR LF terminator.
string filePath = "file.edi";
var lines = File.ReadAllLines(filePath);
string lastLine = lines.Last();
if (!lastLine.EndsWith("\r\n"))
{
lines[lines.Length - 1] += "\r\n";
File.WriteAllLines(filePath, lines);
}
Best Regards.
Jiachen Li
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.