Reading other files through F# Interactive can be tricky when using relative paths. It’s hard to guess what F# Interactive will use as the working directory. Of course you can start using absolute paths but a better alternative is using the built-in constants;
__SOURCE_DIRECTORY__
__SOURCE_FILE__
This allows you to do the following:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let path = System.IO.Path.Combine(__SOURCE_DIRECTORY__,"sample.txt") | |
System.IO.File.ReadAllText path |