You are opening your connection with
INTERNET_FLAG_FROM_CACHE
:
MSDN Quote:
Does not make network requests. All entities are returned from the cache. If the requested item is not in the cache, a suitable error, such as ERROR_FILE_NOT_FOUND, is returned.
So write accesses like creating a FTP directory will of course fail.