iLogic Search For Files Inside Directory

iLogic Search For Files Inside Directory

felix.cortes5K3Y2
Advocate Advocate
2,337 Views
2 Replies
Message 1 of 3

iLogic Search For Files Inside Directory

felix.cortes5K3Y2
Advocate
Advocate

Hi Forum

 

I want to do a search for all the files that contain "20-0446" inside a folder but I am not aware what the syntax is.  Any help is appreciated. Here's my code so far:

 

 

	Dim SubPath As String = "C:\CLEV\PROJECTS\"
	
	'Dim sFiles() As String = System.IO.Directory.GetFiles(SubPath, "*.iam")
	Dim sFiles() As String = System.IO.Directory.GetFiles(SubPath, "20-0446")
	Dim sName As String
	For Each sName In sFiles
		Logger.Info("      " & sName)
	Next

 

Thanks,

Felix

0 Likes
Accepted solutions (1)
2,338 Views
2 Replies
Replies (2)
Message 2 of 3

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @felix.cortes5K3Y2 

Try this 🙂

Dim FileLocation As System.IO.DirectoryInfo = _
New System.IO.DirectoryInfo("C:\CLEV\PROJECTS\")

Dim partOfName As String = "20-0446"
Dim fi As System.IO.FileInfo() = FileLocation.GetFiles("*" & partOfName & "*")

Dim oMsg As String = "Files containing " & partOfName & ":"
For Each oFile As System.IO.FileInfo In fi
	oMsg = oMsg & vbCrLf & oFile.FullName
Next

MessageBox.Show(oMsg, "Found files", MessageBoxButtons.OK, MessageBoxIcon.Information)
Message 3 of 3

felix.cortes5K3Y2
Advocate
Advocate

Hi Joel,

 

Thanks this worked great. I guess I was missing a "*" before and behind my search term

 

Thanks,

Felix Cortes