{{fbdoc item="title" value="CHDIR"}}----
Changes the current drive and directory

{{fbdoc item="syntax"}}##
	[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Chdir** ( [[KeyPgByref|byref]] //path// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgString|string]] ) [[KeyPgAs|as]] [[KeyPgLong|long]]
##
{{fbdoc item="usage"}}##
	//result// = **Chdir**( //path// )
##
{{fbdoc item="param"}}
	##//path//##
		A ##[[KeyPgString|string]]## argument specifying the path to change to.

{{fbdoc item="ret"}}
	Returns zero (0) on success and negative one (-1) on failure.

{{fbdoc item="desc"}}
	Changes the current drive and directory to that specified.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/system/chdir.bas"}}%%(freebasic)
Dim pathname As String = "x:\folder"
Dim result As Integer = ChDir(pathname)

If 0 <> result Then Print "error changing current directory to " & pathname & "."
%%
{{fbdoc item="target"}}
	- Linux requires the //filename// case matches the real name of the file. Windows and DOS are case insensitive. 
	- Path separators in Linux are forward slashes / . Windows uses backward slashes \ but it allows for forward slashes .  DOS uses backward  \ slashes. 

{{fbdoc item="diff"}}
	- In QB, the drive could not be specified.

{{fbdoc item="see"}}
	- ##[[KeyPgCurdir|Curdir]]##
	- ##[[KeyPgMkdir|Mkdir]]##
	- ##[[KeyPgRmdir|Rmdir]]##

{{fbdoc item="back" value="CatPgOpsys|Operating System Functions"}}