Files reading

Hi friends,
I am stuck at one point, please help me.

I have a folder and everyday day one file will be added to that folder.
The file can be .text or .pdf or .docx.

I need to read this file and do extract some data from that file.

But how do I check if it is .pdf or .text or .docx.

Please help me with this

Hi @hanviprebday

=> Use For Each file in Folder and try giving the following syntax inside the loop in assign activity

str_extension= Path.GetExtension(CurrentFile.ToString)

After you get the extension you can use Switch and according to that you can build your workflow.

Hope it helps!!

Hi,

How about the following? We can use Switch activity with CurrentFile.Extension.ToLower

Regards,

@hanviprebday
to read .docx files install package → UiPath.word.activities
to read .pdf files install package → UiPath.pdf.activities

In For each FolderName
assign : PathExtention= Path.GetExtension(CurrentFile)
If PathExtention=“.pdf”
Read Pdf Activity
ElseIf PathExtention=“.txt”
Read text Activity
Else
PathExtention=“.docx”
word application scope activity
in that Read Text activity

Cheers!!