"TonyJ" <jo*****************@telia.comwrote in message
news:ut**************@TK2MSFTNGP02.phx.gbl...
I use this static method GetFiles from the Directory class and I hope to
get
only those files that have file extension ini but I get
all files that begin with ini as the file extension for example *.iniQ and
*.iniP and so on.
This probably happens because you are using the NTFS filesystem with the
default option that generates MS-DOS filenames from long filenames. You can
verify this from a command prompt, typing DIR /X. For instance, create al
file "test.inip" and do a DIR /X. You will get something similar to the
following:
22/11/2007 11:29 992 TEST~1.INI test.inip
This means that the same file is recognized by the system as either
"TEST~1.INI" or "test.inip". In fact, if you type "DIR *.ini" at the command
prompt, you will see "test.inip", because its alias of "TEST~1.INI" matched
the wildcard filter.
Directory.GetFiles(Directory.GetCurrentDirectory() , "*.ini");
Is it possible to only get those for example have *.ini as in my case.
As far as I know, Directory.GetFiles does not have an option to do this
filtering automatically. You will have to loop through the returned files in
your code, removing those that do not match your criteria.