Search code examples
vb.netfull-text-searchfileinfo

How can i get all the files that DO NOT start with "Something"?


The line below fetches all files that start with Cake.

Dim fi As System.IO.FileInfo() = di.GetFiles("Cake*")

How can i write the search pattern to get all the files, that do not start with Cake?


Solution

  • This will be in C#, but it should get you close.

    FileInfo fi[] = di.GetFiles();
    var doNotFiles = fi.Where(file => !file.Name.StartsWith("Cake"));