Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have a code that tell me the details of folder but cant get the details of content in the folder i have can anyone help plss.

The code i have is this

C#
public static void main(String[] args) throws Exception {
    Path path = FileSystems.getDefault().getPath("C:\\Users\\varinder\\Desktop");
    displayFileAttributes(path);
  }

  private static void displayFileAttributes(Path path) throws Exception {
    String format = "Exists: %s %n" + "notExists: %s %n"+ "Readable: %s %n"+ "Writable: %s %n"+ "Size: %s %n";

    System.out.printf(format, Files.exists(path, LinkOption.NOFOLLOW_LINKS),
        Files.notExists(path, LinkOption.NOFOLLOW_LINKS),
        Files.isReadable(path),Files.isWritable(path),
        Files.size(path));
  }
}
Posted
Updated 3-Jun-15 7:47am
v2

I'm not fluent in Java, so I won't post some Java code, but rather some pseudo-code.

At the end of your displayFileAttributes method, you have to iterate over each element of the current path, and recursively call displayFileAttributes for them:
for each (FileSystemElement element in path.getFileSystemElements()) {
   displayFileAttributes(element);
}


Hope this helps.
 
Share this answer
 
The top answer to this question should give you a clear idea: http://stackoverflow.com/questions/1844688/read-all-files-in-a-folder[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900