How to Export Text file without CRLF on very last data record

Corey Fleig 535 Reputation points
2026-09-24T00:59:05.8833333+00:00

I have a data-driven subscription that writes a text file to a shared file area. Everything is fine. However, I added custom code in VB to see if I could strip the very last CRLF at the end of the file (EOF). The report ran, but it didn't remove CRLF.

I Called the VB Function from the 1st data row/cell in the table. Maybe change that?


   
Public Function RemoveEOF()
    Dim filePath As String = "X:\Auto Generated Reports\Eligibility\MSO_MemberFile.txt"

    If System.IO.File.Exists(filePath) Then

        Dim fileContent As String = System.IO.File.ReadAllText(filePath)

        fileContent = fileContent.TrimEnd(ControlChars.Cr, ControlChars.Lf)

        System.IO.File.WriteAllText(filePath, fileContent)

    End If

End Function
SQL Server Reporting Services
SQL Server Reporting Services

A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.


1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.