How can I open a file that is in a different directory?


#1

I created a project via cargo, and i want to open file, that is in a different directory.

How can i do this, if i will use
let mut file = File::open(“i don’t know, what i have to write here”).expect(“Error to open”);

This is not worked
let mut file = File::open("…/some_file.txt").expect(“Error to open”);


#3

When i create file i write:
File::open("src/some_file.txt");

And it worked. Thanks!


#4

Sorry I was confused! Cargo run actually runs the command in the current folder. But I’m glad it works now :wink: