Directory Listing Using .NET


Here's a little d-fn to get some vital statistics about files in a folder more or less purloined from the Dyalog .NET documentation)...

       ⎕vr 'listfiles'
     ∇ listfiles←{
[1]         ⍝ File information for a folder
[2]        ⎕IO ⎕ML ⎕USING←0 3(,⊂'System.IO')
[3]        ⍺←'*.*'
[4]        90::''
[5]        d←DirectoryInfo.New⊂⍵
[6]        fileinfo←d.GetFiles⊂⍺
[7]        0=⍴fileinfo:⍬
[8]        info←⊃fileinfo.(Name Length LastWriteTime)
[9]        info[;1]←{⍬⍴∊(//⎕VFI∘⍕⍵)}¨info[;1]
[10]       ⊂[1]info
[11]   }
     ∇

Calculating the number of days in a year is then simple...

        3↑[0]⊃ listfiles 'c:\dick\mycode\dyalog12\classes\'
 arrays.dogalog  30250  09/06/2008 14:42:53
 blanks.dogalog   4934  09/06/2008 14:29:35
 charts.dogalog  23146  20/06/2008 15:15:29

Notes:
Page created 24 February 2009.
Copyright © Dogon Research 2009.