Hide this comment

Hi,

GetFiles returns a string array, not a list. You can create a ResizeArray<'T> out of it (which is System.Collections.Generic.List<'T>) -- that's the generic version of ArrayList.

F# excels at working with collections. In this case, as you're working with an array, you can use the Array module to filter out what you want.

Here's an example that filters the array, keeping only file names that are less than 8 characters:

1
2
3
4
5
6
7
8
9
10
11
12
 

open System

let directoryName = Console.ReadLine() 

let filesList = IO.Directory.GetFiles(directoryName) 

let res = filesList |> Array.filter(fun x -> x.Length < 8)

printfn "%A" res
By on 11/24/2009 1:24 PM ()Reply
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper

Logging in...