Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

วิธีค้นหาไฟล์ด้วย C#

ใช้ Directory.GetDirectories หาโฟลเดอร์ย่อย แล้ววนลูปค้นหาในโฟลเดอร์ย่อย

string path = @"d:/New/Myfile";
string[] myDir = Directory.GetDirectories(path, "xml", SearchOption.AllDirectories);
Console.WriteLine(myDir.Length.ToString());
foreach (string res in myDir) Console.WriteLine(res);