Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27513

Search for File Using Part of its Name

$
0
0
I am getting a list of part numbers in a spreadsheet. I import the part numbers into a datagrid. For each row of the datagrid I search for that part number. The problem is, that the part number is only part of the file name I am trying to find.

Example of a part number: 100435654
Example of that part number's file name: 100435654_THIN_PTI0987324

I am not sure how to do a like or set wildcards in this instance. Any help would be appreciated.

Code:

For Each row As DataGridViewRow In DataGridView1.Rows
            If Not row.IsNewRow Then
                Dim Qty As Integer = row.Cells(1).Value 'Grabs the Qty from the datagrid and saves as variable.
                Dim FileName As String = row.Cells(0).Value.ToString 'Searches datagrid one row at a time and saves the return as FileName

Try
                   
                    For Each FoundFile As String In My.Computer.FileSystem.GetFiles("C:\Test", FileIO.SearchOption.SearchAllSubDirectories, FileName) 'Takes FileName and searches a directory and child directories


Viewing all articles
Browse latest Browse all 27513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>