How to get size of a directory? #3390
-
Hello there! Cake has FileSize(filePath) for a file but it doesn't work for a directory. Does Cake have an option to get the size of a directory? Thank you in advance! |
Beta Was this translation helpful? Give feedback.
Answered by
augustoproiete
Jun 7, 2021
Replies: 1 comment 1 reply
-
Hey @ArtjomP, there's no equivalent alias for Directories, but you could easily use e.g. var fileSizes = GetFiles("./**/*.*").Sum(FileSize);
Information("File sizes: {0}", fileSizes); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ArtjomP
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @ArtjomP, there's no equivalent alias for Directories, but you could easily use
GetFiles
to enumerate all the files in a directory and sum up the file sizes.e.g.