Get second column data from txt file without trailing space

Good afternoon friends; A query please, I need to obtain the data of the second column (PORTFOLIO) of the txt file without space at the end. In the example there is only one case, but the file has data without a space at the end (correct), but others have an extra space (incorrect.)

I use that data, because I rename the txt files, but since there is an extra space at the end, it causes me problems with other applications.

The original txt file comes with a name similar to this: download20201101_122321.txt

To get the reading of the second row of the .txt I use this:
varTemp.Split(Environment.NewLine(0))(1)

To read the name of the “CARTERA” I use this:
SecondLine.Split("|"c)(1).ToString

Everything above works fine, but it generates a txt file for me as follows:

CDT. GTS PERU LIMA .txt <------- has a space at the end and I don’t want that.

How could I remove only the space at the end of the “CARTERA” name?

Thans!!
CDT. GTS PERU LIMA.txt (367 Bytes)

SecondLine.Split("|"c)(1).ToString.Trim

Thank you very much friend!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.