By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,102 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

how use FtpWebRequest class to access different directory ?

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.