当前位置: 动力学知识库 > 问答 > 编程问答 >

How can i get list of all files with their paths in c

问题描述:

I have read many ways to get list of all files in a directory (e.g. scan a directory to find files in c), but I also want to get their full paths (eg C:\example\file.mp3).

How is it possible?

网友答案:

If you happen to use fts(3) there's the fts_path slot that contains the paths to the files relative to what you put in fts_open().

So I imagine you'd open your directories like this:

char *dirs[] = {"C:\example", NULL}
fts_open(dirs, 0, NULL);

and then you get full paths in the fts_path member of the FTSENT object.

网友答案:

Use dirent.h, it will enable you to populate something like a linked list with the full path of everything in that directory

分享给朋友:
您可能感兴趣的文章:
随机阅读: