In my project, I open a file with some relative path to the executable. I tried to test my code in the F # Interractive window, but it seems to start from a completely different path. How can I change the path / start it from the same path as the project?
I think __SOURCE_DIRECTORY__ can help here.
__SOURCE_DIRECTORY__
You must use compiler directives to separate between using F # Interactive and compiling an F # project.
#if INTERACTIVE let path = __SOURCE_DIRECTORY__ + some_relative_path #else let path = another_relative_path #endif
You can set the current working directory when working in FSI:
#if INTERACTIVE System.IO.Directory.SetCurrentDirectory("<project_path>") #endif