Open file if exists in notepad, else create new file

I’m new to UiPath so bear with me.

I’m trying to create a workflow that:

  1. gets a filename from user
  2. sees if that file exists already, if so open it
  3. if not, create the new file and open it
  4. do stuff within that file.

I’m using notepad. The problem I’m having is that the filename is dynamic, so I’m not sure how to open the file using Use Application/Browser activity. Plus, the activities in the Do scope need to point to that file but it’s not known at development time.

2 Likes

Hi,

How about the following?
We can use argument property to open the file.

Regards,

1 Like

@Terry_Marr

A small enhancement to above workflow

You can use browse for file which gives the users ability to select the file they need

Also instead of use application/browser you can use append to file and write file also or read file to read the data and use message box to display

Cheers

1 Like

Hi @Terry_Marr

Please find the attached xaml file.

open notepad forum.zip (3.4 KB)

If this works for you, please mark this as a solution. So others can refer the same… :slight_smile:
Thanks

1 Like

Thanks for all those who responded to my question. In this case, I was having trouble using Studio with the nested activities because the filename isn’t known until runtime. The solution, which was hinted at by Anil_G, was to forego opening notepad entirely, and simply write what I wanted to write to a text file directly using the “Write Text File” activitiy. It is much faster, and overwrites what’s there, which is what I wanted. I’m not sure this solution would work with other applications, but since notepad is very simple, it works here.

1 Like

You gave me the hint for the solution but suggesting to write to a text file directly, and forget about trying to open notepad at all. Thanks for your help!

1 Like

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