Delete First Two Lines and last line in TXT File

Hello

How can I delete first two lines and last line in TXT/Note pad file.

Thanks
Minal

Hello @minal.patil ,

Can you share the input file here.

Hi @minal.patil

You can try this approach

image

String.Join(Environment.NewLine, strText.Split({Environment.NewLine}, StringSplitOptions.None).Skip(1).Reverse.Skip(1).Reverse)

Refer the xaml

DeleteFirstAndLastLine.xaml (4.8 KB)

a flip flap approach:
arrLines = File.ReadAllLines(“YourPath”).Skip(2).Reverse()Skip(1).Reverse().ToArray

then write it back to text file with:

grafik

OR (similar to Varuns approach)
strFlatten = String.Join(Environment.NewLine, arrLines)
using strFlatten for Write text file activity

1 Like

@minal.patil
May we ask you the following: when the main building block from your selected solution was the flip-flap logic: Skip(2).Reverse()Skip(1).Reverse().ToArray then please flag @kumar.varun2 (instead of me) for the solution as he gave it first as an answer. Thanks

1 Like