- 865 名前:デフォルトの名無しさん [2009/10/15(木) 00:02:10 ]
- c:\data\a\good01.jpg
c:\data\a\bad02.jpg c:\data\a\other03.txt c:\data\b\good04.jpg c:\data\b\bad05.jpg c:\data\b\music06.mp3 c:\data\c\good07.jpg c:\data\c\bad08.jpg のような構造から、goodのjpgだけ抜き出したいと考えました。 string[] photofiles; string[] allphotofiles = Directory.GetFiles(@"c:\data", "*.jpg", SearchOption.AllDirectories); string photolist; foreach(string allphotofile in allphotofiles) { if (allphotofile.Contains("good)){ photolist = photolist + allphotofile + "\n"; } } photofiles = photolist.Split('\n'); でできているのですが、ひどく無駄な処理をしている気がしてます。 こういうときに、LINQを使うとスマートになるんですか?
|

|