FtpSetCurrentDirectory function

Changes to a different working directory on the FTP server.


BOOL FtpSetCurrentDirectory(
  _In_ HINTERNET hConnect,
  _In_ LPCTSTR   lpszDirectory


hConnect [in]

Handle to an FTP session.

lpszDirectory [in]

Pointer to a null-terminated string that contains the name of the directory to become the current working directory. This can be either a fully qualified path or a name relative to the current directory.

Return value

Returns TRUE if successful, or FALSE otherwise. To get a specific error message, call GetLastError. If the error message indicates that the FTP server denied the request to change a directory, use InternetGetLastResponseInfo to determine why.


An application should use FtpGetCurrentDirectory to determine the remote site's current working directory, instead of assuming that the remote system uses a hierarchical naming scheme for directories.

The lpszDirectory parameter can be either partially or fully qualified file names relative to the current directory.

Like all other aspects of the WinINet API, this function cannot be safely called from within DllMain or the constructors and destructors of global objects.

Note  WinINet does not support server implementations. In addition, it should not be used from a service. For server implementations or services use Microsoft Windows HTTP Services (WinHTTP).


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]







Unicode and ANSI names

FtpSetCurrentDirectoryW (Unicode) and FtpSetCurrentDirectoryA (ANSI)

See also

FTP Sessions
WinINet Functions