Assign file date with wildcard?

I’m trying to assign a variable with the date (modified or creation) of a .xlsx-file in a specific location.

After an extensive search of the forum I found Post #250529:

new FileInfo(“filepath”).CreationTime.ToString(“yyyy/MM/dd”)

and it works great. However, I will not know the file name and need to use a wildcard. I found this post with the syntax about using a * Post #133486


If I combine this two like:

new FileInfo(“c:\testfolder\”,"*.xlsx").CreationTime.ToString(“yyyy/MM/dd”)

I get error:
Main.xaml: Compiler error(s) encountered processing expression “new FileInfo(“c:\testfolder\”,”*.xlsx”).CreationTime.ToString(“yyyy/MM/dd”)".
Overload resolution failed because no accessible ‘New’ accepts this number of arguments.

Any help to a newbie is very appreciated!


Hi ,

I would suggest first use ,

filesList = directory.getfiles(“Location”,“searchPattern”)

And loop through each file , get the creation date time and then add the file to new list.

Thank You

Hi @erik1

follow below pseudo code

for each item in Directory.GetFiles(Destination_folder_path)
FileName = New FileInfo(item)
message box FileName.Name
message box Filedetails.LastModifiedDate

variables Filedetails and FileName are of type FileInfo (Browse for type System.IO.FileInfo in variables panel)

note that, FileName.Name and Filedetails.LastModifiedDate(i.e. var_name.Name, var_details.LastModifiedDate) and not .ToString

hope this is helpful

Thank you for your reply. I can clearify that the directory only contains one xlsx file. But the name of the file change.

Maybe I should stress that I’m really a newbie. I will look into your suggestion. Maybe it’s good to know that the path only contain one xlsx-file at a time but with different names.

Sure hoped there were a solution to using wildcard like in my first post.


StrFile = Directory.GetFiles("yourPath","*.xlsx")(0)

This will get one file from that folder.

Great, thank you.

But how do I assign the date of that file to a variable?

Sorry if this is basic knowledge, but I can’t get it to work.


@erik1 - Please share your sample file name …

You wanted to take the date from the file name or take the modified date of that file and assign it to a variable ?

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