How To Read/Write To Text File – In UiPath

We use text files a lot during our daily work, So does the RPA.

Let’s see how to read and write to Text file!!!

Example

Implementation using UiPath :

Let us implement a workflow to write the data to a text file, then read data from it and then again append some text to it.

Different Text file Operations:

1. Writing data to a text file
2. Reading data from a text file
3. Appending data to a existing text file

Step 1:
Drag “Input Dialog” activity into the designer panel and create a variable to store the user-provided value.

Text File Operations(Read and Write) 1.PNGText File Operations(Read and Write) 2.PNG

Step 2:
Drag “Write Text File” activity to write the data provided by the user to a text file.
(If the supplied .txt file is not available in the directory, the activity will create a new file with that name)

Text File Operations(Read and Write) 3.PNG

Step 3:
Drag “Read Text File” activity to read the data from the provided text file.

Text File Operations(Read and Write) 4.PNG

Step 4:
Drag “Message Box” activity to display the text obtained from the above step.

Text File Operations(Read and Write) 5.PNG

Step 4:
Drag “Append Line” activity into the designer panel to append the text to an existing text file and pass the inputs .i.e data that is to be appended and text file’s path.

(When we use “Append Line” activity, it will not overwrite the text file data but
instead, it will write the new data from next new line unlike “Write Text File”)

Text File Operations(Read and Write) 6.PNG

Step 5:
Finally, execute the workflow and observe the output carefully 🙂

Click here to download the Source Code…

Hope it has helped you…

Leave a Reply

%d bloggers like this: