How to Read from Notepad file

Hi
I have 5 lines in notepad file [file.txt]:
eg.
Resources
Video
Documents
Help
ContactUs

I want to fetch the line’s text one by one, and save it in variable.

I am using:

  1. Select file Activity to select the file at run time [file.txt].
  2. Then Assign Activity and assigning variable of String type = File.ReadAllText(selectedFile).
    opList = File.ReadAllText(selectedFile)
  3. Then used For each loop

But no luck
Attached the file2nd-copy.xaml (8.1 KB)

1 Like

HI @shruti.o.gupta,

you can use Read Text File Activity, it will return the String value.

after getting the value using split Environment.NewLine option spit the value to array
For loop through the array value you can get the each value.

arrvalue= strvalue.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries)

Regards,
Arivu

1 Like

@shruti.o.gupta, In For each use this item in opList.Split(CChar(Environment.Newline)) and change the type argument to string.
Inside body of for each remove everything and use write line and include item

Regards,
Dominic :slight_smile:

1 Like

Hi @shruti.o.gupta,

Please find updated workflow, I hope this is what you wanted.

Reg,
Sarthak

2nd-copy.xaml (6.8 KB)

1 Like

Thanks it worked !!

2 Likes

Thanks

1 Like

buddy after splitting how you stored each line of notepad to new string

1 Like