//得到文件夹下所有文件的文件名 String^ dir = label1->Text; DirectoryInfo^ di = gcnew DirectoryInfo(dir); array<FileInfo^>^fiArr = di->GetFiles(); Collections::IEnumerator^ myEnum = fiArr->GetEnumerator(); while(myEnum->MoveNext()) { FileInfo^ fri = safe_cast<FileInfo^>(myEnum->Current); listBox1->Items->Add(fri->Name); } //得到文件夹下所有子文件夹名 array<DirectoryInfo^>^diArr = di->GetDirectories(); Collections::IEnumerator^ myEnumDir = diArr->GetEnumerator();; while(myEnumDir->MoveNext()) { DirectoryInfo^ difo = safe_cast<DirectoryInfo^>(myEnumDir->Current); listBox2->Items->Add(difo->Name); }