I would like to read a file in an F# console app when I select the file to be opened with the app, like in this code for C#.
The main module does not seem to take arguments, is there any method I can do this?
Thanks!
Asked
Active
Viewed 145 times
1

Isaac Howie
- 11
- 5
1 Answers
3
You can create an F# console application with an explicit main
function by having the following as the last function in the last file of your project:
[<EntryPoint>]
let main argv =
printfn "%A" argv
0
The argv
parameter is the array of command line arguments. This sample just prints it so that you can see what parameters your application gets.
Alternatively, you can also get the command line arguments using the GetCommandLineArgs
method provided by the System.Environment
object:
System.Environment.GetCommandLineArgs()

Fyodor Soikin
- 78,590
- 9
- 125
- 172

Tomas Petricek
- 240,744
- 19
- 378
- 553