开发者

List of all .txt file [closed]

开发者 https://www.devze.com 2023-02-21 12:20 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_StackOverflow中文版 Closed 11 years ago.

Hi I want to write a program that give a path in my system and goes to that path and search in that path and sub-directory of path and list all of .txt file . please help me . thanks .


The Following code will list all your files in "C:\Windows\System32" directory (SYSDIR for XP system). Add it in your code however you want.

DIR *dir;
struct dirent *ent;
        dir = opendir ("c:\\Windows\\System32");
if (dir != NULL) {

  /* print all the files and directories */
  while ((ent = readdir (dir)) != NULL) {
    printf ("%s\n", ent->d_name);
  }
  closedir (dir);
} else {
  /* Can not open directory */
  perror ("");
  return EXIT_FAILURE;
}


Create an object of type QDir. This can be used to navigate to the desired folder, e.g. by using dirobj.cd("/mypath/somewhere"). Then use dirobj.entryList(QStringList("*.txt", "*.otherext", ...) to retrieve a list of the files found.

0

精彩评论

暂无评论...
验证码 换一张
取 消