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

JBrianClark

Posts

2

Joined

Wed Jul 01, 2009 7:36 am

Checking for existing directory

by JBrianClark » Wed Jul 01, 2009 7:44 am

Hey All,

I am using VB.NET 2008 w/ the latest free version of this component.

For the sake of this post I have declared this component as objFTPConnection

There does not seem to be a good way to check if a directory exists.

The objFTPConnection.Exists method seems to only work for files.

The objFTPConnection.ChangeWorkingDirectory states it returns type boolean -- yet this does not seem to work. I can not compare this to a true/false clause.

What is the best way to check if a directory exists?
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: Checking for existing directory

by support2 » Wed Jul 01, 2009 8:08 am

Try ChangeWorkingDirectory - if it fails with an exception, it does not exist.

We will be adding DirectoryExists and FileExists methods very soon - DirectoryExists will do the above.
no avatar
User

JBrianClark

Posts

2

Joined

Wed Jul 01, 2009 7:36 am

by JBrianClark » Wed Jul 01, 2009 8:16 am

Thank you for the prompt reply.

Any idea on time frame for those commands?

I guess I will do a try/catch for the change directory.

Thanks!
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Wed Jul 01, 2009 4:36 pm

Planned for the next release but that won't be for a few weeks. We'll implement it in exactly the same way.
no avatar
User

y2kdis

Posts

5

Joined

Fri Jan 22, 2010 12:04 am

by y2kdis » Thu Feb 11, 2010 9:47 am

Sorry for resurrecting an old thread but I'm looking for this feature too.
The latest edt free version has the FTPConnection.Exists function that checks if a file exists or not. I tried to use it to check for the existence of a directory and I had mixed results.
It works for zFtpServer but not for FileZilla server. Both are hosted on a Windows machine.
Any idea how I can have a foolproof but straightforward checking for a directory's existence? I am quite hesitant on going the GetFileInfos route as I have quite a number of files and subdirectories.
no avatar
User

EDT Support

Posts

905

Joined

Mon Apr 26, 2004 3:03 pm

by EDT Support » Thu Feb 11, 2010 11:34 am

no avatar
User

y2kdis

Posts

5

Joined

Fri Jan 22, 2010 12:04 am

by y2kdis » Fri Feb 12, 2010 1:32 am

Thanks for the input!
The only issue I have with it, although a very minor one, is the use of try-catch statement as it comes with a small overhead.
Also, does ChangeWorkingDirectory work even if the target directory is several levels up or down?
For instance I am on /FolderA and the target folder is /FolderA/FolderA1/FolderA1a.
no avatar
User

EDT Support

Posts

905

Joined

Mon Apr 26, 2004 3:03 pm

by EDT Support » Fri Feb 12, 2010 8:21 am

I expect that the time spent in the try-catch is negligible when compared with the time spent communicating with the remote host while executing the cwd.

The exact behaviour of cwd depends on the server. I've never come across a server that doesn't support changing multiple directory levels in one operation. Once or twice I've seen reports of a server that doesn't support absolute directories, though I think they were particularly ancient ones. So the method I listed won't work universally, but it should work on the vast majority of servers.

- Hans (EnterpriseDT)

Who is online

Users browsing this forum: No registered users and 23 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron