I wanted add data in existing text file. How can I do it instead of write text file activity

I wanted add data in existing text file. How can I do it instead of write text file activity

Any suggestions would be helpful .

Thanks,
Nawaz.

use APPEND LINE activity @Mohammed_Nawazuddin
image

@Mohammed_Nawazuddin
try this as well (invoke code)

String data=File.ReadAllText(“filepath”)
data.append(“data to append”)
File.WriteAllText(“filepath”,data)

Hello @Mohammed_Nawazuddin

You can use Append Line activity. If the file is already existing then it will use that file, else it will create a new text file.

Hi Jack,

Thanks for you message. I tried the above code and getting bit error.I am not what is data in it. Is it string variable. I have my all data in read_data variable. Please validate the below codeeand let me know if any change needs to be done.

image

Thanks,
Nawaz.

can you upload your xaml @Mohammed_Nawazuddin

Hi,

Please find the attached xaml file.

[
Main.xaml (5.0 KB)
](https://)

1 Like

this will work @Mohammed_Nawazuddin

using (invoke code c#)
File.AppendAllText(@"C:\Users\Mohammed.Nawazuddin\OneDrive\Documents\UiPath\Write\processApp.txt", read_data + Environment.NewLine);

Main (1).xaml (7.0 KB)

Instead of path I am trying to pass the variable but its getting faulted.Please look into the xaml fi

Main.xaml (5.5 KB)
le

here
Main (2).xaml (5.5 KB)

dont name your variable File, because File is a name of the module e.g. File.WriteAllText

if you have a variable named File uipath will get confused, it doesnt know whether you’re referring to the variable/module name

Hi Jack,

Its working in my local machine but the same logic is not working in my client system. Please find the below screenshots

hover your mouse over this and tell me what the error says

Please find the below screenshot.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.