Reputation: 11649
I have a file Roman_Numbers.txt
, and i put it next to my *.fsx
file in the folder of project. Then I tried to read this file using the following function in the fsx
file:
open System.IO
let readNumbersFromFile(path:string)=
let lines = File.ReadLines(path)
let ListOfNumbers = List.ofSeq(lines);
checkConvert ListOfNumbers
readNumbersFromFile(@"Roman_Numbers.txt")
But i face with this erorr:
System.IO.FileNotFoundException: Could not find file 'C:\Users\Salman\AppData\Local\Temp\Roman_Numbers.txt'.
> File name: 'C:\Users\Salman\AppData\Local\Temp\Roman_Numbers.txt'
The question is: Why it should look for C:\Users\Salman\AppData\Local\Temp\Roman_Numbers.txt'
this address, meanwhile
my project is not here and more over i clearly mention Roman_Numbers.txt
as a source of file?
How can i fix it?
Upvotes: 0
Views: 2537
Reputation: 1159
Use SOURCE_DIRECTORY
readNumbersFromFile( __SOURCE_DIRECTORY__ + @"/Roman_Numbers.txt")
Upvotes: 1
Reputation: 324
I guess you should copy the file into your package folder and specify the complete path into your code. Try that and see the result
Upvotes: 1