The code works as expected, but the search is case-sensitive, could that be why?
Also, this code is better:
Code:
Dim folder As String = Request.QueryString("f")
Dim search As String = Request.QueryString("i")
Dim filenames As New List(Of String)
For Each filepath As String In IO.Directory.GetFiles(folder, "*.jpg")
filenames.Add(IO.Path.GetFileNameWithoutExtension(filepath))
Next
Dim currentIndex As Integer = filenames.IndexOf(search)