简体   繁体   中英

Open file with F# project

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!

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM