Handling FTP Directories with Spaces


Some FTP servers may not correctly process directory paths that contain spaces when they are passed directly to certain methods. For example, a directory such as:

/SomeDir/Another Dir

This may cause operations such as directory listing to fail when the path is used directly.

To access directories that contain spaces, change into the directory first using the Command property with the FTP CWD command. After changing the working directory, perform the directory listing on the current directory.

Example approach:

FTP1.Command = "CWD /SomeDir/Another Dir"
FTP1.ListDirectory "./"

By changing the working directory first and then listing the current directory, the server can correctly interpret the path even when spaces are present in the directory name.

We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.