Open last file in folder/"Value cannot be null"-"VisualBasicValue 1" ERROR

Dear Community,

I would like to open the latest file from a folder.
For this I know the following code:
String.Join(“”, Directory.GetFiles(MEMORYPATH, “*”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(NUMBER) )

The last times the code worked but recently I get the following error code. I thought it was the file, but even when I tested it in a new file it doesn’t work anymore.

“Sequence: Value cannot be null. (Parameter ‘path’)”
or
Use Excel File: Compilation is required to run the VisualBasicValue`1 expression activity type. Make sure that the workflow has been compiled.

How can I call the Last File inside a folder? Gladly also the last file with a certain beginning e.g. BEISPIEL_XXXX and the file BEISPIEL_1334 is opened.

Thanks in advance! :slight_smile:

Hi @nowak.moritz

Try replacing the inverted comma I guess you recently upgraded to latest version and this developed in a older version

And try using a assign activity instead just to be sure

cheers

Hi @nowak.moritz,

They are almost close, just replace this code

String.Join(“”, Directory.GetFiles(MEMORYPATH, “”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(Directory.GetFiles(MEMORYPATH, “”,SearchOption.AllDirectories).count-1) )

I have change below

NUMBER = Directory.GetFiles(MEMORYPATH, “*”,SearchOption.AllDirectories).count-1

Best,
Rajkumar

What should I replace the quotation marks with (and which ones? :))
String.Join(“”, Directory.GetFiles(STORAGEPATH, “*”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(NUMBER) )


Unfortunately the same error code…

dont pass the value in default value . use assign activity like below

image


What else could it be?

HI @nowak.moritz

Just remove the inverted comma and write it again in the assign.

cheers

Hi @nowak.moritz,

Use below code, just copy past

String.Join(“”, Directory.GetFiles(FilePath,““,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(Directory.GetFiles(FilePath,””,SearchOption.AllDirectories).count-1) )

Best,

1 Like

@nowak.moritz,

then type below mentioned value manually

1 Like

Sample Xaml

Sequence13.xaml (6.6 KB)

1 Like

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