Get full path of files that contains specific term in their file name in vb.net

Hakan
Hakan used Ask the Experts™
on
I've found a code for file searching at specific path for multiple filter below but i'd like to apply it for vb.net application? How is it possible to convert it to vb.net ?

var files = Directory.EnumerateFiles("C:\\path", "*.*", SearchOption.AllDirectories)
            .Where(s => s.Contains("test_file") );

Open in new window


Finally i would like to get list of files with full path which  are contains my string parameter.

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chief Technology Ninja
Distinguished Expert 2018
Commented:
Hi Hakan,

Please give this code snippet a try:
Dim files = Directory.EnumerateFiles("C:\path", "*.*", SearchOption.AllDirectories).Where(Function(s) s.Contains("test_file"))

Open in new window


Regards,
Chinmay.

Author

Commented:
Hi Mr. Patel,

Your reply is extremely helpful, thanks. I'm bit newbie like this functions how can i found large informations about them.

Thanks again.
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Hi Hakan,

I started with VB6 and then fell in love with C# but over the period of time had to do a lot of code reviews (and migrations) as people prefer C# over VB.Net (As you can see with the lack of examples, content, samples on VB.Net) for various reasons. During these reviews / migrations I could see common patterns especially features which were built later on were pretty much same in both C# and VB.Net (hence it is easy to convert a LINQ code.

Also if you want to study the LINQ code I used this resource a LOT when I was trying to wrap my head around LINQ - https://code.msdn.microsoft.com/LINQ-Sample-Queries-13a42a54

Regards,
Chinmay.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial