469,610 Members | 1,779 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,610 developers. It's quick & easy.

FTPWebRequest and CD

Could someone show me how to use the FtpWebRequest and change to a different
directory? Changing directories is not listed as one of the methods, but I
believe it can be done--just can't figure out how.
Feb 17 '07 #1
6 9095
The methos is:

ftpObject.ChDir(m_sRemotePath)

I just did this for a recent project - it works great. The remote path
is without the \ at the end.

T
William LaMartin wrote:
Could someone show me how to use the FtpWebRequest and change to a different
directory? Changing directories is not listed as one of the methods, but I
believe it can be done--just can't figure out how.
Feb 17 '07 #2

"William LaMartin" <la******@tampabay.rr.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Could someone show me how to use the FtpWebRequest and change to a
different directory? Changing directories is not listed as one of the
methods, but I believe it can be done--just can't figure out how.
I spent last week downloading a dozen or so examples using ftpwebrequest and
NONE of them worked as downloaded.

I am trying to find out how to use ftpwebrequest.KeepAlive property. The
documentation says
"When the KeepAlive property is set to false, the control connection is
closed when you call the Close method."

BUT there is no accessable close method for ftpwebrequest.

It took me a week to discover that instances of ftpwebrequest can not be
created.

Demilitarized code? Pardon the metaphor.

Respectfully Richard,


Feb 19 '07 #3

"William LaMartin" <la******@tampabay.rr.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Could someone show me how to use the FtpWebRequest and change to a
different directory? Changing directories is not listed as one of the
methods, but I believe it can be done--just can't figure out how.
I think I might have found what I have been looking for the
ftpwebrequest.method accepts a "string" value.

I have not tried the standard ftp commands i.e. cd (change directory),
close, etc.

ftpwebrequest.method ="cd"

Richard
Feb 20 '07 #4
>
ftpwebrequest.method ="cd"
The above does not work either.

Have to parse the path name with the directory path then create a new
"ftpwebrequest". AFAIK

Richard
Feb 20 '07 #5
On Feb 16, 11:50 pm, "William LaMartin" <lamar...@tampabay.rr.com>
wrote:
Could someone show me how to use the FtpWebRequest and change to a different
directory? Changing directories is not listed as one of the methods, but I
believe it can be done--just can't figure out how.
you cannot use the command directly, but you can modify the uri
parameter to achieve the same result.

Let's say you're using the following format:

String uri = "ftp://myFtpUserName:myFtpUserPassword@myFtpUrl";

FtpWebRequest Request = (FtpWebRequest)WebRequest.Create(uri);

Request.Method = "LIST";

The above example will bring you to your user's directory and list all
the contents there. Now let's say you want to go 2 directories
backwards and list the contents there (provided your user has
permissions to do that). You close the previous FtpWebRequest and
issue a new one with this uri

uri = "ftp://myFtpUserName:myFtpUserPassword@myFtpUrl/%2E%2E/%2E%2E";

This is equivalent to logging in with your user's credentials and then
using cd ../../

Note: if you try using the ".." directly without escaping them the
uri class will strip them, so "ftp://
myFtpUserName:myFtpUserPassword@myFtpUrl/../.." is equivalent to
"ftp://myFtpUserName:myFtpUserPassword@myFtpUrl/"

Now let's say you want to go to another user's directory which is one
level above the root. If you don't specify a user name and password
it's equivalent to logging in as anonymous user. Then you issue a new
FtpWebRequest with the following uri

"ftp://myFtpUrl/%2F/anotherUserDir"

This is equivalent to logging in as anonymous and then doing

Cd /

cd anotherUserDirectory

Feb 20 '07 #6
Then you issue a new
FtpWebRequest with the following uri

"ftp://myFtpUrl/%2F/anotherUserDir"

This is equivalent to logging in as anonymous and then doing

Cd /

cd anotherUserDirectory
I understand.

I was hoping there was a way to keep the connection alive between requests.
Like a telnet connection.
The FtpWebRequest class comes with a value "FtpWebRequest.KeepAlive" but it
does not seem to do anything.

I can think of no reason for keeping the connection alive except when
sending passwords in the clear would require sending the password only once
versus every access.

Without spending money for accurate documentation this problem could lead to
be a big waste of time

Thanks,
Richard
Feb 20 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Kevin Spencer | last post: by
7 posts views Thread by jose.lopes.cruz | last post: by
2 posts views Thread by Ian Hannah | last post: by
reply views Thread by Buddy Home | last post: by
9 posts views Thread by Waldy | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.