Is there an easy one line invoke code activity?

Hi guys!

Sometimes I found myself in need to run one line of vb.net code. I am lucky if the code actually returns something - I can use Assign activity with the code you need to run on the right side of the equation. If there is nothing to return, I have to use Invoke Code activity, that is not very convenient for just one line of the code, because you need to import all the arguments before you can use them.

Example functions:

  1. File.ReadAllLines - a good example for use in an Assign activity.
  2. File.WriteAllLines - doesn’t return anything and I have to use Invoke Code activity. For example, if I use 3 variables in filename/path, I’d have to pass a total of 4 arguments inside the activity to run this. Which I think is a bit overkill to import lots of variables every time for just one line of code.

Basically, I’d use Invoke Code with no issues, if it’d be able to access all of the variables available in the scope from which the call was made.

So my question is, how do you do such one-liners?

Hi @cubx,

We have write text file activity available to write the text into a file… Is it the one you are looking for?

hi @cubx

did you tried Invoke Method ?

1 Like

Not exactly, I gave example, but this is not the only case I have. I just want to have an easy way to call one-liners in general.

Also, write text file accepts a string, but can’t work with array or list of strings.

This seems complex but might work. I’ll check it out. Any idea how to use it for File.WriteAllLines for example?

@cubx set Target type as System.Io.File , method name as WriteAllLines

pass two arugument one is string which represent File Path
another one is Array [String] which is content of text to write in notepad

1 Like

Thanks a lot! This is what I needed!

P.S. Sorry I never took the time to say thank you, but it’s better late than never :slight_smile:

1 Like

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