Home > Back-end >  Access to a directory number of files and directories (including subdirectories)
Access to a directory number of files and directories (including subdirectories)

Time:04-30

 
Int fileCount=0, folderCount=0;
Long length=0;
The File folder=new File (" D: \ \ lalla ");
The File list=[] folder. ListFiles ();
For (the File File: list) {
{if (file. IsFile ())
FileCount++;
Length +=file. The length ();
} else {
FolderCount++;
}
}



But this can only access to the current directory for less than his subclass ah

CodePudding user response:

Daily top

CodePudding user response:

Recursive...

CodePudding user response:

Fine amount are stupid could say

CodePudding user response:

Recursive calls:
Write a method, parameter is the folder path;
Methods internal access to all files, judgment, if it is a file, print (or other), if it is a folder, will continue to call this method,

CodePudding user response:

Well well know thank you
  • Related