How can I make F # Interactive window use the same path as the project?

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?

+7
source share
2 answers

I think __SOURCE_DIRECTORY__ can help here.

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 
+10
source

You can set the current working directory when working in FSI:

 #if INTERACTIVE System.IO.Directory.SetCurrentDirectory("<project_path>") #endif 
+3
source

All Articles