Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.6k views
in .NET FTP by (1.3k points)
Hi,
I'm using an SFTP connection and when checking if a folder exists, I'm using ftpClient.DirectoryExists(..). If it doesn't, then I'm getting the following line in the error log: ERROR EnterpriseDTLog - GetHandleResponse: The file path does not exist or is invalid.

I saw on another post that the way the DirectoryExists() method works is it tries to ChangeWorkingDirectory() to the given one, and returns false if that fails. I presume that's why the logger receives an exception message.

My question is, why does the DirectoryExists() method not traverse the folders and use GetFileInfos() to check if the folder exists? Wouldn't it be better not to rely on a try-catch? Furthermore, you'd be able to return more information, eg: if the folder does exist, but the user does not have permission to access it etc.?

Thanks,
Graeme

5 Answers

0 votes
by (161k points)
We've considered using GetFileInfos(), but that also has its downsides. Your current directory may be be unlistable, but still permit changing into a subdirectory that you can't see.
0 votes
by (1.3k points)
Does it make sense that we're getting "GetHandleResponse: No such file" in the logs?
0 votes
by (161k points)
You will need to post the pertinent section of the log file.
0 votes
by (1.3k points)
2013-03-19 10:02:54,336 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - ChDir(2/5)
2013-03-19 10:02:54,336 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - ResolveRemotePath('2/5'); [cwd='/']
2013-03-19 10:02:54,336 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - Resolved to '/2/5'
2013-03-19 10:02:54,336 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - Transmit 17 bytes
2013-03-19 10:02:54,336 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - Remote window size decreased to 4034159
2013-03-19 10:02:54,343 [7] [(null)] [(null)] [(null)] DEBUG EnterpriseDTLog - RepeatCallback received 116 bytes
2013-03-19 10:02:54,344 [7] [(null)] [(null)] [(null)] DEBUG EnterpriseDTLog - ProcessPacket pt=SSH_MSG_CHANNEL_DATA
2013-03-19 10:02:54,344 [7] [(null)] [(null)] [(null)] DEBUG EnterpriseDTLog - Received message (type=104,len=41)
2013-03-19 10:02:54,344 [7] [(null)] [(null)] [(null)] DEBUG EnterpriseDTLog - AddMessage(1611) - added to store
2013-03-19 10:02:54,344 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - Opening directory /2/5
2013-03-19 10:02:54,344 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - Transmit 17 bytes
2013-03-19 10:02:54,344 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - Remote window size decreased to 4034142
2013-03-19 10:02:54,352 [7] [(null)] [(null)] [(null)] DEBUG EnterpriseDTLog - RepeatCallback received 116 bytes
2013-03-19 10:02:54,352 [7] [(null)] [(null)] [(null)] DEBUG EnterpriseDTLog - ProcessPacket pt=SSH_MSG_CHANNEL_DATA
2013-03-19 10:02:54,352 [7] [(null)] [(null)] [(null)] DEBUG EnterpriseDTLog - Received message (type=101,len=62)
2013-03-19 10:02:54,352 [7] [(null)] [(null)] [(null)] DEBUG EnterpriseDTLog - ErrorCode|Status=2
2013-03-19 10:02:54,352 [7] [(null)] [(null)] [(null)] DEBUG EnterpriseDTLog - AddMessage(1612) - added to store
2013-03-19 10:02:54,352 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] ERROR EnterpriseDTLog - GetHandleResponse: The file path does not exist or is invalid.
2013-03-19 10:02:54,381 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - Rename('2/0'=>'2/5')
2013-03-19 10:02:54,381 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - ResolveRemotePath('2/0'); [cwd='/']
2013-03-19 10:02:54,381 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - Resolved to '/2/0'
2013-03-19 10:02:54,381 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - ResolveRemotePath('2/5'); [cwd='/']
2013-03-19 10:02:54,381 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - Resolved to '/2/5'
2013-03-19 10:02:54,381 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - Transmit 25 bytes
2013-03-19 10:02:54,381 [22] [admin] [z4bitey3lmgn5dxhzdb0vgyt] [2] DEBUG EnterpriseDTLog - Remote window size decreased to 4034117

This happens when using DirectoryExists() where the directory does not exist. It doesn't occur when using GetFileInfos() in a custom DirectoryExists() method.
0 votes
by (1.3k points)
Hi, I just wanted to follow up on this post as we're still getting that error in our logs

Categories

...