Filter by use Directory.GetFiles?

I have code as below.

Directory.GetFiles(Path_DownloadTextfile,"*.txt").Where(Function(w)Convert.ToDateTime(New FileInfo(w).LastModifiedDate).ToShortDateString.Equals(Today.ToShortDateString)).FirstOrDefault()

I have value name as string = Report

If I want filter that filename = Report.txt by pass value.

Please guide me about it.

@fairymemay

You mean want to filter text files whose name is equal to Report ?

If yes then try below expression.

   Directory.GetFiles("FolderPath",varFile+"*.txt")

Here, varFile = Report

1 Like

@lakshman If I ignore upper or lowercase in code (file)

Example varfile = Report

But output expect don’t mind uppercase , lowercase —> check filename match only.

How to set it ?

@fairymemay

It is not case sensitive. So it will ignore case and look for matching filename.

1 Like

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