How to | Locate and Use Files
The Wolfram Language offers support for a large number of file formats for importing, exporting, or other operations. It has several standard locations where it looks for files. You can change these locations to place other directories in the Wolfram Language's default search path.
By default, the Wolfram Language is able to use files in the directories that appear in $Path:
View your current working directory by evaluating Directory:
You can see a list of all files in the current working directory by evaluating FileNames:
There are a number of methods you can use to access a file if it is in a directory that is not on $Path or in your current working directory.
For example, you can specify the full path of a file or folder that you want to use. See How to: Insert a File Path to view the different methods available for doing this.
Or, use SetDirectory to change your current working directory:
To use a file that is in one of the directories on $Path or your current working directory, you only need to specify the name of the file.
Use ResetDirectory to reset the current working directory to its previous value:
You can also append a directory to $Path.
Note that the change to $Path is temporary, and the value is reset when you restart the Wolfram System or the kernel.
To make the change permanent, you can add the previous AppendTo command to one of the following two init.m files. Here, FileNameJoin is used to construct a full file path from $UserBaseDirectory and $BaseDirectory:
Just like $Path, $UserBaseDirectory, and $BaseDirectory, other system variables can be used to construct file paths. Some commonly used system variables that represent directories are $RootDirectory, $HomeDirectory, and $InstallationDirectory.