Guest User

Untitled

a guest
Jun 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. open System.IO
  2.  
  3. type FolderStatistic = { Name : string
  4. Size : int64 }
  5.  
  6. let calculateFolderSize (folder : string) =
  7. Directory.GetFiles folder
  8. |> List.ofSeq
  9. |> List.sumBy (fun f -> FileInfo(f).Length)
  10.  
  11. let subfolders : DirectoryInfo array =
  12. let folder = new DirectoryInfo(@"C:\\tmp")
  13. folder.GetDirectories()
  14.  
  15. subfolders
  16. |> List.ofArray
  17. |> List.map (fun x -> { Name = x.Name; Size = calculateFolderSize x.FullName })
  18. |> List.sortByDescending(fun x -> x.Size)
Add Comment
Please, Sign In to add comment