views:

710

answers:

1

Can someone tell me how to change directories using FtpWebRequest? This seems like it should be an easy thing to do, but I'm not seeing it.

EDIT

I just want to add...I don't have my heart set on FtpWebRequest. If there's a better (easier) way to do FTP in .NET please let me know.


Apparently there's no way to do it using a live connection, you need to change the uri to trick ftpwebrequest into using a different request (thanks Jon).

So I'm looking for a 3rd party client...

Some of the open source solutions I tried didn't work too well (kept crashing), but I found one open source solution that's passed some of my preliminary tests (.NET FTP Client).

+3  A: 

There's a blog post from Mariya Atanasova which shows how you can fake it - basically you have to put the directory on the URL.

I suspect you may be better off with a dedicated FTP library though - one that doesn't try to force everything into the WebRequest way of doing things. I haven't personally used any 3rd party libraries for this, but a search for "FTP library .NET" finds lots of candidates.

Jon Skeet
I tried to open source libraries from codeproject and they were both giving me a ton of issues when connecting to a filezilla ftp server (don't know how well they work on iis ftp servers). I guess I may have to buy a component. Thanks for the answer though.
Giovanni Galbo
Whatever client library you use, change to passive mode as soon as you can, assuming it gives you the option. That's much more likely to work through firewalls etc.
Jon Skeet