I have to write the code to insert the space in middle of falt file.
I have text as below, each line column length should be same
123
123256
123323
the above string should looks like
123---
234256
987323
After 123 we need space. could you suggest how to do this.
I have loaded the file into string dr = file.ReadToEnd();
Use the string
split
function to split your lines at the line break (either\n
orSystem.Environment.NewLine
, depending your desires). Iterate over the returned array toTrim()
each string, then use thePadRight
function to produce a new string of the desired length with the desired trailing characters. Then use one of the manyIO
write functions to output to a new file or overwrite the existing file.