How to make a XAML file tell its full path?

Hello,

given the project structure below, do you know how to make test.xaml tell its path with an activity inside of test.xaml w/o providing any information about the (relative) path within test.xaml?

  • Project Root
    • Folder A
    • Folder B
      • Folder B1
      • Folder B2
        - test.xaml

Please, assume that the name of test.xaml is not unique in the project.

Cheers, Emerald.

HI @Emerald

You can use Environment.CurrentDirectory and from there you can append the relative path to it

cheers

Hi @Anil_G ,

that doesn’t help. I don’t want to append the relative path. I want that the xaml file tells me its full path without specifying any path-related information of the xaml file within the xaml file.

Best, Emerald.

Hi @Emerald

Please check this

Cheers

Hi @Anil_G,

thanks but I have already seen this post. The proposed solution in this post doesn’t solve my problem. I’m working in a test automation project. Each xaml file is a test case. So, there’s is no main.xaml.

Best, Emerald.

1 Like

Hi @Emerald,

We are in the same shoes as you. This is how we find out our full path file to our test cases. It works on both Studio and all Robot types.

One condition is that the filename is unique and a duplicate does not exist in other folders of the project if so you will get multiple hits in the check (if) and the last file in the loop will be set to out_ThisFileFullPath

Hope this helps. Here is the sample file.
GetMyFullPath.xaml (10.8 KB)

Thanks, @jeevith.

Unfortunately, I am looking for a solution that doesn’t require the file name to be unique. For example, in VBA you can get the current file path and name by ThisWorkbook.FullName. I’m looking for something similar for xaml files.

Best, Emerald.

had you checked these discussions?:

and also here

Thanks, @ppr.

Yes, I have read this post.

Its solution only gives the name of the current xaml file but not its path.

Best, Emerald.

dive more into the details and check more when they are talking about context, location…

I checked the post.

It’s not solving my problem.

Did I miss something?

If so, please tell me.

Best, Emerald.

Hi @ppr,

I have tried every single suggestion from this thread before. The Last reply from @rpamania is the easiest way to get the current workflow name. But it returns only the file name not the relative path. But then @Emerald does not want to add relative path or do any checks with file names as I suggested above.

Sadly none of those approaches will work here.


The only place I found some hope is in this suggested solution :


PoweShell? :frowning:

I also tried PowerShell, but UiPath executor (project.json location) takes precedence
image

Also these suggested solutions in the link below only return the project.json path (UiPath executor dictates this) and not the workflow running. c# - how to get current application path in wpf - Stack Overflow

We therefore concluded that the suggested solution noted above is the way to go for now. With one limitation that we cannot have duplicate file names.

Thanks, @jeevith.

Yes, invoking PowerShell was also one of my desperate attempts. :wink:

Best, Emerald.

It’s solved.

The solution has been shared here.

Best, Emerald.

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