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
vvaidya
(Vinay Vaidya)
January 26, 2018, 6:41pm
2
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
vvaidya
(Vinay Vaidya)
January 29, 2018, 7:02pm
4
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
@ovi can you please check at convenience.FolderBrowse.xaml (4.3 KB)
ovi
(Viorela Preda)
January 30, 2018, 10:14am
5
Reproduced.
@Gabriel_Tatu can you please confirm?
1 Like
can you upload the xaml again, its empty.
arivu96
(Arivazhagan A)
January 30, 2018, 11:03am
7
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.
vvaidya
(Vinay Vaidya)
January 30, 2018, 11:46am
9
Thanks for checking. Do you think it is only for this specific function?
arivu96
(Arivazhagan A)
January 30, 2018, 11:59am
10
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
tmartin
(Tracy)
February 1, 2018, 9:57pm
11
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?
vvaidya
(Vinay Vaidya)
February 1, 2018, 11:50pm
12
This is unclear, can you explain more about it.
tmartin
(Tracy)
February 2, 2018, 1:50pm
13
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?
when i run this it stops right here:
vvaidya
(Vinay Vaidya)
February 2, 2018, 2:40pm
14
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
tmartin
(Tracy)
February 2, 2018, 3:53pm
15
This worked great and thanks so much. have a great day and a great anniversary day!
1 Like