Discuss (FTP), (FTP on .NET CF) and (FTPS, SFTP and SCP).

DirectoryExists

no avatar
User

Graeme

Posts

37

Joined

Fri Oct 14, 2011 8:14 pm

Location

Dublin

DirectoryExists

by Graeme » Fri Mar 15, 2013 9:24 pm

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
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: DirectoryExists

by support2 » Fri Mar 15, 2013 11:47 pm

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.
no avatar
User

Graeme

Posts

37

Joined

Fri Oct 14, 2011 8:14 pm

Location

Dublin

by Graeme » Tue Mar 19, 2013 7:51 pm

Does it make sense that we're getting "GetHandleResponse: No such file" in the logs?
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Tue Mar 19, 2013 10:40 pm

You will need to post the pertinent section of the log file.
no avatar
User

Graeme

Posts

37

Joined

Fri Oct 14, 2011 8:14 pm

Location

Dublin

by Graeme » Tue Mar 19, 2013 10:46 pm

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.
no avatar
User

Graeme

Posts

37

Joined

Fri Oct 14, 2011 8:14 pm

Location

Dublin

Re: DirectoryExists

by Graeme » Fri Aug 29, 2014 6:43 pm

Hi, I just wanted to follow up on this post as we're still getting that error in our logs

Who is online

Users browsing this forum: No registered users and 25 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron