469,269 Members | 1,006 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

how use FtpWebRequest class to access different directory ?

hi everyone

I have a quick question when i use the FtpWebRequest.

What I need to do is that:
Connect a FTP server,check whether there is a folder
if not,create it, then changed the path to the new folder
If use the command line to do that,it just use the "CD" command
can finish.But there is not the command in WebRequestMethods.Ftp

how could do that?if i want to change the directory when i has been
login?

Thanks
Kevin Lee

Nov 7 '06 #1
3 9436
Hi Kevin,

Try setting the "Method" property to "CD".

Please let us know if that works for you.

--
Dave Sexton

"Kevien Lee" <ir************@gmail.comwrote in message
news:11**********************@f16g2000cwb.googlegr oups.com...
hi everyone

I have a quick question when i use the FtpWebRequest.

What I need to do is that:
Connect a FTP server,check whether there is a folder
if not,create it, then changed the path to the new folder
If use the command line to do that,it just use the "CD" command
can finish.But there is not the command in WebRequestMethods.Ftp

how could do that?if i want to change the directory when i has been
login?

Thanks
Kevin Lee

Nov 7 '06 #2
Hi Kevin,

"The Method property determines which command is sent to the server. You set
the Method by using the strings defined in the public field members of the
WebRequestMethods.Ftp class. Note that the strings defined in the
WebRequestMethods.Ftp class are the only supported options for the Method
property. Setting the Method property to any other value will result in an
ArgumentException exception."

"FtpWebRequest.Method property"
http://msdn2.microsoft.com/en-us/lib...od(VS.80).aspx

Sorry, but I don't think it can be done using FtpWebRequest. You'd have to
reconnect by calling the Create method again. I guess FtpWebRequest is really
just meant to encapsulate a single request, not an entire session.

You should look into some of the other FTP components available for .NET such
as those mentioned here:

[watch for wrapping]
http://groups.google.com/group/micro...edef59acfd86c1

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:OU**************@TK2MSFTNGP03.phx.gbl...
Hi Kevin,

Try setting the "Method" property to "CD".

Please let us know if that works for you.

--
Dave Sexton

"Kevien Lee" <ir************@gmail.comwrote in message
news:11**********************@f16g2000cwb.googlegr oups.com...
>hi everyone

I have a quick question when i use the FtpWebRequest.

What I need to do is that:
Connect a FTP server,check whether there is a folder
if not,create it, then changed the path to the new folder
If use the command line to do that,it just use the "CD" command
can finish.But there is not the command in WebRequestMethods.Ftp

how could do that?if i want to change the directory when i has been
login?

Thanks
Kevin Lee


Nov 7 '06 #3
Dave Sexton:
Thanks very much.

The FtpWebRequest is too simple :(

Dave Sexton wrote:
Hi Kevin,

"The Method property determines which command is sent to the server. You set
the Method by using the strings defined in the public field members of the
WebRequestMethods.Ftp class. Note that the strings defined in the
WebRequestMethods.Ftp class are the only supported options for the Method
property. Setting the Method property to any other value will result in an
ArgumentException exception."

"FtpWebRequest.Method property"
http://msdn2.microsoft.com/en-us/lib...od(VS.80).aspx

Sorry, but I don't think it can be done using FtpWebRequest. You'd have to
reconnect by calling the Create method again. I guess FtpWebRequest is really
just meant to encapsulate a single request, not an entire session.

You should look into some of the other FTP components available for .NET such
as those mentioned here:

[watch for wrapping]
http://groups.google.com/group/micro...edef59acfd86c1

--
Dave Sexton

"Dave Sexton" <dave@jwa[remove.this]online.comwrote in message
news:OU**************@TK2MSFTNGP03.phx.gbl...
Hi Kevin,

Try setting the "Method" property to "CD".

Please let us know if that works for you.

--
Dave Sexton

"Kevien Lee" <ir************@gmail.comwrote in message
news:11**********************@f16g2000cwb.googlegr oups.com...
hi everyone

I have a quick question when i use the FtpWebRequest.

What I need to do is that:
Connect a FTP server,check whether there is a folder
if not,create it, then changed the path to the new folder
If use the command line to do that,it just use the "CD" command
can finish.But there is not the command in WebRequestMethods.Ftp

how could do that?if i want to change the directory when i has been
login?

Thanks
Kevin Lee
Nov 7 '06 #4

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 Bob Phillips | last post: by
reply views Thread by Buddy Home | last post: by
6 posts views Thread by William LaMartin | last post: by
9 posts views Thread by Waldy | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.