Can you call Directory.GetFiles() with multiple filters?

前端 未结 26 2958
逝去的感伤
逝去的感伤 2020-11-22 05:25

I am trying to use the Directory.GetFiles() method to retrieve a list of files of multiple types, such as mp3\'s and jpg\'s. I have t

26条回答
  •  不知归路
    2020-11-22 05:51

    Or you can just convert the string of extensions to String^

    vector   extensions = { "*.mp4", "*.avi", "*.flv" };
    for (int i = 0; i < extensions.size(); ++i)
    {
         String^ ext = gcnew String(extensions[i].c_str());;
         String^ path = "C:\\Users\\Eric\\Videos";
         array^files = Directory::GetFiles(path,ext);
         Console::WriteLine(ext);
         cout << " " << (files->Length) << endl;
    }
    

提交回复
热议问题