June 19, 2021, 10:26pm
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
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
If I combine this two like:
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!
I would suggest first use ,
filesList = directory.getfiles(“Location”,“
And loop through each file , get the creation date time and then add the file to new list.
June 20, 2021, 4:05am
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
June 20, 2021, 8:52am
Thank you for your reply. I can clearify that the directory only contains one xlsx file. But the name of the file change.
June 20, 2021, 8:58am
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.
June 21, 2021, 1:02pm
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 ?
June 24, 2021, 1:04pm
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.