• 0

GetFiles() not working as I want


Question

I'm loading all the text files on a specific directory and for that I have: Dim notesFiles As FileInfo() = dirInfo.GetFiles("*.txt")

However, FileInfo array will have files that termiante in .txt and .txt????

Where the questions marks can be any letter and can be just one letter or more... I want it to scan exactly only text files .txt, how can I do that?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

You can't according to the docs:

The matching behavior of searchPattern when the extension is exactly three characters long is different from when the extension is more than three characters long. A searchPattern of exactly three characters returns files having an extension of three or more characters. A searchPattern of one, two, or more than three characters returns only files having extensions of exactly that length.

The following list shows the behavior of different lengths for the searchPattern parameter:

"*.abc" returns files having an extension of .abc, .abcd, .abcde, .abcdef, and so on.

"*.abcd" returns only files having an extension of .abcd.

"*.abcde" returns only files having an extension of .abcde.

"*.abcdef" returns only files having an extension of .abcdef.

Link to comment
Share on other sites

This topic is now closed to further replies.