I want to get all images filepath name in a directory

Hi, All.

I want to get all images filepath name in a directory.
and that diretory is got from draginfo of dragEvent.

My code is here:
void ofApp::dragEvent(ofDragInfo dragInfo){

if( dragInfo.files.size() > 0 ){
    ofDirectory dir(dragInfo.files[0]);
    // all file
    for(int i = 0; i < dir.size(); i++){
        ofLog() << dir.getPath(i) << endl;
ofSetWindowShape(img1.getWidth(), img1.getHeight());


But I met this error:
“[ error ] ofDirectory: listDir:() source directory does not exist:”

What’s wrong to me ?


Hi, are you dragging a file or a folder?
you coul do something like

for(int i = 0; i < dragInfo.files.size(); i++){
		ofFile fl(dragInfo.files[i]);
			cout << "File: ";
			//load the file
		}else if(fl.isDirectory()){
			cout << "Directory: ";
			//load the directory s files.
		cout << f << ", ";
1 Like

Hi, @roymacdonald

Thank you.

I’ll try that, and report.

from @bemoregt.