IndexOf is a method of type string . I suspect that somewhere in ...doing stuff you are working on $file in such a way that it is considered as System.IO.FileInfo .
I suspect this in part because I am trying to reproduce it in my environment and make it work:
function doSomething ($file) {
Do you generally work with $file or use it to modify other files? If you don't mind the object being [System.IO.FileInfo] , you can use $file.fullname to return the path string. This assumes that you have not changed it so that it becomes a collection of FileInfo objects.
source share