how use FtpWebRequest class to access different directory ?

  • Thread starter Thread starter Kevien Lee
  • Start date Start date
K

Kevien Lee

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
 
Hi Kevin,

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

Please let us know if that works for you.
 
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/library/system.net.ftpwebrequest.method(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/micr...0cwb.googlegroups.com&rnum=1#fbedef59acfd86c1
 
Dave Sexton:
Thanks very much.

The FtpWebRequest is too simple :(

Dave said:
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/library/system.net.ftpwebrequest.method(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/micr...0cwb.googlegroups.com&rnum=1#fbedef59acfd86c1

--
Dave Sexton

Dave Sexton said:
Hi Kevin,

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

Please let us know if that works for you.
 
Back
Top