Home > Article > Development Tools > How to use relative paths in vscode
How to use relative paths in vscode
The relative paths in vscode are different from those in general editors. For specific differences, please refer to the following table
Symbol | vscode | General |
---|---|---|
“./2 .txt" | Relative to the working path (where the .vscode folder is located) | Relative to the current running file |
"2.txt" | Relative to the working path | Relative to the current running file |
"/2.txt" | Relative to the disk root directory | Relative to the disk root directory |
Usage example:
Requirements: The working path is as above, The execution file is readfile .py, and you need to obtain the 1.txt file
Solution 1: Use the corresponding relative path
, that is, according to the working path To find the relative path is "./greatProject/godsearch/1.txt"
Solution 2: Change launch.json settings
Add the statement
"cwd": "${fileDirname}"
to the configurations to become a regular relative path mode
To obtain the relative path, just "./1.txt" or "1.txt"
Recommended related articles and tutorials: vscode tutorial
The above is the detailed content of How to use relative paths in vscode. For more information, please follow other related articles on the PHP Chinese website!