Help with reading part of and xml file using VB.NET

How do I check if 7 of the xml files in my application's folder contains a particular text (i.e. BEL)

For example I am selecting countries from a combobox, therefore combobox.Text  = BEL, I need to make sure 7 of the files in my application's folder contains BEL before I run my search, the seven files are in the following format: LinKABEL.xml, LinKBBEL.xml, LinKCBEL.xml, LinKDBEL.xml, LinKEBEL.xml, LinKFBEL.xml, LinKGBEL.xml.

Thanks,

Victor
vcharlesAsked:
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.

käµfm³d 👽Commented:
The files themselves contain the text "BEL", or the filenames contain "BEL"?
0
vcharlesAuthor Commented:
Hi,

The filenames.

Victor
0
käµfm³d 👽Commented:
You could use a bit of LINQ goodness:

Imports System.Linq
Imports System.IO

...

Dim yourDirectory As String = Directory.GetCurrentDirectory()  ' Assumes you haven't changed the working directory of your application

If Directory.EnumerateFiles(yourDirectory, "*BEL*.xml").Take(7).Count() >= 7 Then
    ' run search
End If

Open in new window

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
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

vcharlesAuthor Commented:
The files are in a subfolder (LinkFiles) of my application's folder. How do I modify the code to look for the files in the LinkFiles subfolder?

Thanks,

Victor
0
käµfm³d 👽Commented:
Dim yourDirectory As String = Directory.GetCurrentDirectory()

yourDirectory = Path.Combine(yourDirectory, "LinkFiles")

Open in new window

0
vcharlesAuthor Commented:
Thank you, will try it and get back to you tomorrow.
0
vcharlesAuthor Commented:
It works!

Thank You.

Victor
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
.NET Programming

From novice to tech pro — start learning today.