How to delete data present in a text file

studio

#1

How to delete data present in a text file


#2

Hello!

Could you be more specific?

Regards,


#3

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


#4

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


#5

@ndivya u can do by using send hot key activity


#6

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


#7

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


#8

@ndivya before send hotkey use open application activity


#9

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’)


#10

@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

Regards,
Dominic :slight_smile:


#11

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 .


#12

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


Clear the file
#13

@ndivya Please go through attached file it works

DeleteText in Textfile.zip (2.1 KB)


Clear the file
#14

Thank you ,It’s working now


#15

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