Recutory directory tree with Visualc ++ 6.0

zhaozj2021-02-11  196

Recipheasion of Visualc 6.0 Recursive Contents Tree Beijing Information Engineering Ma Wen Xiao ---- In the SDI project, by using CFiledialog and CFILEFIND classes, you can not only realize existing lookup features on Windows desktops, but also flexibly expand the lookup conditions. For example, The following program will output in the Output window of Visualc 6.0, the read-only file of all lengths of less than 500 bytes in the output window: #include

/*contain

_Getcwd, _CHDIR prototype * /

Void f0 () {

Char x [256], y [256];

CfileDialog FD (TRUE);

/ * Construct "File Open" dialog box with true value * /

_Getcwd (x, 256); / *

The current working directory is deposited in X array * /

IF (fd.domodal () == idok) {

/ * During the CFiledialog dialogue,

First select the C: / Windows directory,

Then choose the next ordinary file, such as NotePad.exe,

Or enter a file that does not exist, such as f0.non * /

_Getcwd (y, 256);

/ * Current work directory C: / windows deposits Y array * /

F1 (y); / * Call F1 function with Y content * /

}

_CHDIR (X); / * Current work directory placed back X content * /

}

Void F1 (cstring x) {

BOOL B; cfilefind f;

/ * Considering recursion, only local variables * /

_chdir (x); b = f.findfile ("*. *");

/ * Current work directory is set to X,

Then check all the files * /

While (b) {

B = f.FindNextFile ();

IF (f.IsDirectory ()) {

/ * The current file is a directory * /

IF (! f.isdots ())

{F1 (f.GetFilePath ());

/ * Directory file is not "." And "..",

Use full path to call it * /

}

}

Else

IF (F.IsreadOnly () && f.getlength

() <500) {AFXDUMP <"/ n"; AFXDUMP

---- After the procedure is normal, the Output window will display the execution result. In addition, the use of CMemoryState class checks, which has proven that this program has not caused memory leakage.

转载请注明原文地址:https://www.9cbs.com/read-4092.html

New Post(0)