c# - Get all file names in a directory ignoring file extension -
i have folder files this:
foo.map foo.ind foo.dat bar.map bar.ind bar.dat readme.txt readme.html
i distinct file names without extension, i.e. foo, bar, readme
.
of course can use directory.getfiles()
, make loop path.getfilenamewithoutextension()
wonder if there short way, maybe 1 line, e.g. using linq?
how about:
directory .getfiles() .select(f => path.getfilenamewithoutextension(f.name)) .distinct();
Comments
Post a Comment