Test file type


#1

Hi. I cant see a simple solution for this yet: I'm using a FileChooser and FileDragAndDropTarget, with the chooser I can easily restrict the selectable file types, I need a similar system to restrict drag & drop files to the same types. Is there a way to test the type of a file? e.g. check if it's an audio file that is .wav, .mp3, .aiff. Or is there a solution I'm missing?

 


#2

Hello!

The member function isInterestedInFileDrag might be what you're looking for. For example:

bool MyDragAndDropTarget::isInterestedInFileDrag (const StringArray& files)
{
    for (auto fileName : files)
        if (! fileName.endsWith (".wav"))
             return false;

    return true;
}

Hope this helps!


#3

Just what I needed thanks. I had not been looking at that function with enough detail before.