Cargo.toml error

I've installed rust on my computer and use VSCode to write code. When i write some rust code and try to build it with Cargo build on terminal, i get an error, could not find Cargo.toml in c:\Users\(directory name) or any parent directory. How can i resolve this? thanks

How do you go about starting to write rust code? The easiest way is using the cargo tool to automatically set up your rust project. The way I currently do it with VSCode: just navigate in the command line to some place where you want to create a project, then execude cargo new name_of_my_project, afterwards navigate into the newly created directory (cd name_of_my_project) and open the directory with vscode (execude the code . command). The command line kept open seperately can still be useful for manually invoking some cargo commands on the side, such as for example cargo doc --open to generate and open the documentation for your code in a web-browser.

For further reference on how rust projects are structured and how you can compile them manually, you can start out by reading the "getting started" section of the rust book.