09/02/17 14:06:14
複数のフォルダに写真を整理していて、そのなかにある特定の日付(たとえば3月)の写真だけを抜き出したいと思っています。
string[] files = Directory.Getfiles("c:/photo", "*.jpg", SearchOption.AllDirectories);
string list = "";
foreach(string file in files) {list = list + file + "\r\n";}
MessageBox.Show(list);
とやって、いま、次のようなリストを入手しました。
このうち3月のみを取り出すのはどうしたらよいでしょう。
いちばん簡単なのは、*の部分に書くことかと思い、
string[] files = Directory.Getfiles("c:/photo", "200803*.jpg", SearchOption.AllDirectories);
としてみましたが、フォルダ名とファイル名にわかれていて結果は空になってしまいます。
あと、3月以前(01、02)とする方法もあわせて教えてください。
c:/photo/20080407eventname/photo.jpg
c:/photo/20080401eventname/photo.jpg
c:/photo/20080317eventname/photo.jpg
c:/photo/20080310eventname/photo.jpg
c:/photo/20080304eventname/photo.jpg
c:/photo/20080303eventname/photo.jpg
c:/photo/20080224eventname/photo.jpg
c:/photo/20080203eventname/photo.jpg
c:/photo/20080127eventname/photo.jpg