I use assign activity for get latest file excel as below.
Variable File as string = Directory.GetFiles(“C:\Users\Tiff\Downloads”,"*.csv”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime)(0)
Firstly, may we ask about your project`s expression Language? I think your code and the suggested fixes are using VB syntax, but will not work in C#. You can check that info in your project.json.
String.Join(“parameter”,Directory.GetFiles(FolderPath,”*”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(n))
Here:
Take(n): defines how many file paths you require i.e., n=1 or 2 or 3, and goes on.
It will sort the latest file based on creation time from all files.
parameter- It will separate the file paths with this parameter.
If you enter ‘,’ there then the output will be like this filepath1, filepath2.
It will be like this we are combining all the file paths.
If you want only one latest file from a folder then follow as shown below:
String.Join(“ ”,Directory.GetFiles(FolderPath,”*”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1))
@Maria99
ok this explains the validation issue. @marci080 was refering to the project.json file from your UiPath project. Just close uipath, navigate to Uipath project. locate the project.json file. Edit it in an editor and change the programming languague to VB
When you newly create or open an xaml in UiPath Studio, there are some folders and files generated automatically. Amongst them is the project json file.
(Just like what happened when I opened your Reconcile.xaml file in my Downloads folder.)
You may learn more about it here
Though I personally do not recommend manually editing the json file because some activities may not work/appear properly and will make debugging more complicated.
Anyways, to address your original issue, maybe you can create a blank project (in VB) and just test first the suggested fix to check if the error no longer appear. Then start from there ~
To me it looks more like a generic syntax error.
The code highlighting suggests that the last part of your expression is interpreted as an unfinished string, purely goin on the syntax highlighting.
If I look closely at the screenshot it looks as if different types of double quotes are used, which might cause the syntax error. Did you by any chance copy paste the ‘c:\users…’ part from a word document?
Your expression looks fine in syntax. Try typing it in manually fully once, and see if that makes the difference…
Yes, I agree @Jeroen_van_Loon ! My original answer was about syntax error including the misused quotation marks since C# is somehow “strict”
Though I found out that if in VB, @Maria99 `s original code will amazingly work even without changing the mismatched quotations!
VB
Directory.GetFiles(“C:\Users\Tiff\Downloads”,"*.csv”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime)(0)
or
Directory.GetFiles("C:\Users\Tiff\Downloads","*.csv",SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime)(0)
C#
Directory.GetFiles("C:\\Users\\Tiff\\Downloads","*.csv",SearchOption.AllDirectories).OrderByDescending(d => new FileInfo(d).CreationTime).ElementAt(0)
Though this ticket isresolved, I just want to add this detail for future reference.