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).
You have to close the current connection:
And open a new one with an other uri:
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.
Edit: jcolebrand (in case of 2006 blog linkrot possibility)
Instead of using ListDirectory method of FTPWebRequest you can use ListDirectoryDetails method of FtpWebRequest .
From That you can use regular expression to get value you want. Thats it,It work fine for me in my case