Search for a file in a folder

I need a way to search for a file using the current date. The file will look like the following FTP.log_20141213_120043.log. I know how to format the search string I need to use which in this example would be 20141213. I also will know the folder ahead of time.  I just need to know how to find the file based on the formatted date.
dthillsrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
Areplanningto list the files in the folder and doing a string/pattern match?
0
dthillsrAuthor Commented:
I will be working with a folder that will contain a large number of log files that are created daily. I want to access the file that is created daily and import the contents into a database. I need to use a pattern match of the date like in the example above 20141213 to locate the file.
0
arnoldCommented:
Io.directoryinfo has a getfiles('*pattern*.*') that will return the list of items that match the pattern.
Ms has an example in the reference link below.

https://msdn.microsoft.com/en-us/library/system.io.directoryinfo.exists(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dthillsrAuthor Commented:
That works and I also found that the code below will do what I need.

Dim dirs As String() = Directory.GetFiles("D:\WorkRelated\Test Files\Files", "*20141213*")
        Dim dir As String
        For Each dir In dirs
            MsgBox(dir)
        Next
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.