Query for list of files and folders in root directory

后端 未结 3 1468
我寻月下人不归
我寻月下人不归 2021-02-05 14:46

I would like to get a list of files and folders in the root directory without having to sort through all the files. Is there a query that would do this?

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 15:21

    This code will display all files and folder of your ROOT DIRECTORY. just copy and paste this code and you will get all your root's file and folder.

     List result = new ArrayList();
        Files.List request = null;
    
        try {
              request = mService.files().list();
              FileList files = request.setQ("'root' in parents and trashed=false").execute();
              result.addAll(files.getItems());          
              request.setPageToken(files.getNextPageToken());
            } 
          catch (IOException e)
          {
            System.out.println("An error occurred: " + e);
            request.setPageToken(null);
          }
    
     //Print out all the files and folder of root Directory  
      for(File f:result)
      {
          System.out.println("recvd data are: "+f.getTitle());
      }
    

提交回复
热议问题