Home > Software engineering >  Consult the Window FileFind traverse error file
Consult the Window FileFind traverse error file

Time:10-09

 CFileFind finder. 
BOOL blNotEmpty=finder. FindFile (strDir + _T (" \ \ *. * "));
While (blNotEmpty)
{
BlNotEmpty=finder. The FindNextFile ();
Cstrings filename=finder. GetFilePath ();
STD: : cout & lt; If (finder. IsDots ())
continue;
if (! Finder. IsDirectory ())
{
Files. The push_back (filename);
}
The else
{
if (! Finder. IsTemporary ())
{
GetFileNames (files, finder. GetFilePath () + _T ("/"));
}
}
}

The default is C disk

CodePudding user response:

System (" dir/b/a - d c: \ \ *. * & gt; D: \ \ allfiles TXT ");
//read file d: \ \ allfiles TXT content of C: \ \ under the names of all files
System (" dir/b/a - d/s c: \ \ *. * & gt; D: \ \ allfilesinsub TXT ");
//read file d: \ \ allfilesinsub TXT content that is C: \ \ under the names of all files contain subdirectories
System (" dir/b/active directory c: \ \ *. * & gt; D: \ \ alldirs TXT ");
//read file d: \ \ alldirs TXT content of C: \ \ under the names of all the subdirectories
Please remember, can use the shell command to get the file and folder information or manipulate files, folders had better use the shell command to get or operation, and don't use all sorts of API access to or operation, because when it comes to illegal folder name or illegal filename or illegal file length, illegal file date, compressed file, link files, sparse file... All sorts of unexpected situations, such as API can deal with incomplete or into an infinite loop, and shell commands not,
If disrelish black window system that the system ("... ") is replaced by WinExec (" CMD/c... ", SW_HIDE);

CodePudding user response:

Cstrings filename=finder. GetFilePath ();
CStringA filenameA=(cstrings) filename;
STD: : cout & lt;
  • Related