Directory.GetFiles not working

Greetings!

I’m working my way past the Level 1 Foundation training Lesson 2 Control Flow Loops and found a strange situation.

I had already created a project, so to do these lessons, just added a new sequence under the project. In trying to create the example in the Lesson where it gets the files in a directory and puts them in the output, UIPath wasn’t recognizing Directory. It seemed as if it needed a using statement but I could find no place to do that.

After a lot of messing around with it and it not working, even listening to that portion of the training video several times, I went and did it in the main.xaml that is created upon project creation. And it worked. Why? Why does an added sequence/flow not have those basic functions built into them? Is this the case? And if so, how do I add them to a new one I created?

tl;dr How do I include File.IO to sequences or flows other than the first Main in the project?

Thanks!

Jon

Could you provide a screenshot of the error? Not sure if I’m able to follow.

My first guess without full understanding is that the new file you created didn’t have the File.IO namespace imported. In your workflow, next to the variables/arguments tab is a tab called imports. Click that and type in File.IO If my guess is correct then that would solve your issue


Including screen shot for clarity.

I saw the Dependencies and Manage Packages but not the Imports down below. That’s what I needed to do.

I’m still having an issue. I was getting the error ? on the Assign items because System.IO was not imported. Must not default on new items but it was included on my Main.xaml page. As soon as I added that into the Imports, the error went away. However, I still get an error.

It doesn’t show the error in the flow but it still errors out on that. Any thoughts?

Thanks for the reply!

Jon

I can only put one image per replay so here is the error image:

Thanks!

Jon

How about System.IO.Directory.GetFiles(x) ?