Setting a default value for Select Folder

I’m using Select Folder. After browsing to and selecting a folder, I would like persist that value and next time have Select Folder default to that location. I don’t see any way to do this with the UiPath control and assume I’ll need to resort to some VB functionality. Has anyone done something like this?

ddk

I don’t think you can assign a predefined path to Select folder. Attached is simple alternate way.

SelectFiles.xaml (6.0 KB)

1 Like

Thanks Vinay. That’s pretty cool, and almost exactly what I think we need.

ddk

We could do the same for folders using “FolderBrowserDialog”, but there seems to be some issue.

In the assign activity once i start assigning value to folder.RootFolder , I get below error without even running the code ( wait for 5 secs).Version 2017.1

image

@ovi can you please check at convenience.FolderBrowse.xaml (4.3 KB)

Reproduced.

@Gabriel_Tatu can you please confirm?

1 Like

can you upload the xaml again, its empty.

Hi @Gabriel_Tatu,
i checked this code its working for me
@ovi,@vvaidya - can you verify this

1.Use Invoke code activity (Need latest version UiPath 2017 and above)
2.variable → FBD ->System.windows.forms.FolderBrowserDialog(variable type)
3.variable → DR ->System.windows.forms.DialogResult(variable type)

Pass this two arguments to invoke code.(both are in argument)
use this below code


FBD.RootFolder = Environment.SpecialFolder.MyComputer
FBD.SelectedPath = “C:\temp”
MsgBox(FBD.SelectedPath)
If FBD.ShowDialog = DR.OK Then
End If


Regards,
Arivu

1 Like

its a studio issue/defect.

Thanks for checking. Do you think it is only for this specific function?

Hi @vvaidya,

I am not sure , you can use FolderBrowserDialog to achieve this.

C# code.
using(var fbd = new FolderBrowserDialog())
{
DialogResult result = fbd.ShowDialog();

if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
{
    string[] files = Directory.GetFiles(fbd.SelectedPath);

    System.Windows.Forms.MessageBox.Show("Files found: " + files.Length.ToString(), "Message");
}

}

Regards,
Arivu

I’m having a similar issue. I can get UiPath to open the folder but it will not select the CSV folder. So do you have any suggestions?

This is unclear, can you explain more about it.

OK. I can open the folder and then i do a Select File and it will not select any files it wants me to select the files from the Windows Explorer. Does that help?
image
when i run this it stops right here:

It helps. So do you want to select a specific file?

Why don’t you do something like this

Today’s file, if multiple will select First

String File = Directory.GetFiles(“C:\temp”,“sepPlanApp_”+now.ToString(“yyyyddM”)+“*.csv”).First()

Latest file

String File = Directory.GetFiles(“C:\temp”,“*.csv”).OrderByDescending(Function(file) New FileInfo(file).LastWriteTime).First()

Thanks,
Vinay

This worked great and thanks so much. have a great day and a great anniversary day!

1 Like