Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a text file in which the record are like this:

69|M2200|D9612|0000000|20070101|
87|M20888|D5710|0032600|20071101|


Now i want to remove the last '|'

And read all the data as a detaset.
Posted
Updated 23-Nov-15 22:54pm
v2
Comments
phil.o 24-Nov-15 4:52am    
And what have you tried?
Nawab Ahmad 24-Nov-15 4:53am    
FileInfo table = new FileInfo("C:\\Filename.something");

string strTable = table.OpenText().ReadToEnd();

string rep = strTable.Replace("old char", "new char");
Tomas Takac 24-Nov-15 4:55am    
This is a valid solution, post it as such. But please fix it first as the OP has asked to remove the last pipe.
Patrice T 24-Nov-15 5:02am    
Post this in your question.
use Improve question
F-ES Sitecore 24-Nov-15 5:03am    
Read it line by line then remove the last char using TrimEnd

1 solution

row.TrimEnd("|");

https://msdn.microsoft.com/en-us/library/system.string.trimend(v=vs.90).aspx
 
Share this answer
 
Comments
CPallini 24-Nov-15 5:22am    
The idea is good, the code not correct.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900