How to delete data present in a text file

How to delete data present in a text file


Could you be more specific?


I want to clear or delete data present in notepad based on condition

clear or delete data present in notepad based on condition(i.e for example if notepad has three rows then delete data from notepad)

@ndivya u can do by using send hot key activity

CTRL+A hotkey is not working,as before this need to click on somewhere in notepad ,how to do this activity

Maybe use Type into again to type empty string ("") and ensure Empty field checkbox is checked.

@ndivya before send hotkey use open application activity

when using type into or send hotkeys option-use " indicate on screen" to point out the open notepad application.
use lowercase letters for shortcuts - Eg ctrl+ ‘a’ (not ‘A’)

@ndivya, Not sure about your exact requirement ! But why not give a try ?

  1. Read text file → Save to string variable
  2. Manipulate string (Use string.Remove) and remove unwanted rows from it
  3. Write back to a text file

Dominic :slight_smile:

Thanks for your answers
I am using read text file activity, then used send hotkey Ctrl+a still it didn’t worked.
My requirement is i have three rows in text file just want to delete them .

Quick Google showed:
File.WriteAllText(path, String.Empty)
In UiPath that would be:


@ndivya Please go through attached file it works

DeleteText in (2.1 KB)

1 Like

Thank you ,It’s working now

How can we delete a specific row from the text file?
@andrzej.kniola @indra

i am not getting it…

please help…


OP, Did you ever figure it out? I am trying to figure out a similar issue and wanted to see. For me, I need to search through the rows of a .txt file and if there is a ‘123456789’ found, cut that row and paste into a separate notepad file. Your issue seemed to fit some of that.