How to Integrate OpenFileDialog into the InArgument of a Custom Activity

I am currently working on acquiring a file path in string format within a custom activity. However, I am looking to enhance it by implementing a ‘Browse For File’ dialog, specifically using the OpenFileDialog

In my scenario. I am uncertain about how to integrate this into an InArgument that accepts a string, along with an icon that triggers the ‘Browse File’ dialog. I have been searching for a solution, but I couldn’t find one that is directly applicable to custom activity code.

here is my code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Activities;
using System.ComponentModel;
using System.Windows.Forms;
namespace Open_Dialog_Flow_Activity
{
    public class OpenDialog : CodeActivity
    {
        [RequiredArgument]
        [Category("Input")]
        public InArgument<string> FilePath { get; set; } // i want to implement the Dialog Here 

        protected override void Execute(CodeActivityContext context)
        {
            
            // You can perform additional logic here based on the selected file path
            Console.WriteLine("Selected File Path: " + selectedFilePath);
        }

       
    }
   
   
}

Hi,

As far as i know, it’s difficult to set button for opening “OpenFileDialog” in properties panel.
If you need a button for opening “OpenFileDialog” on activity in designer panel, UiPath activity Creator will help you because it contains FilePathControl

Regards,

1 Like

Thanks for your input on this, and currently working on activity creator is out of scope for this activity, maybe in future I will try to add it , thanks again

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