Improve this question. Martin Prikryl k 46 46 gold badges silver badges bronze badges. Add a comment. Active Oldest Votes. You have to implement the recursion yourself: List the remote directory Iterate the entries, downloading files and recursing into subdirectories listing them again, etc.
Your options are: Do an operation on a file name that is certain to fail for file and succeeds for directories or vice versa. If that succeeds, it's a file, if that fails, it's a directory. You may be lucky and in your specific case, you can tell a file from a directory by a file name i. But many servers use a different format. Create url ; listRequest. ListDirectoryDetails; listRequest. Add listReader. Create fileUrl ; downloadRequest.
DownloadFile; downloadRequest. Read buffer, 0, buffer. I'm the author of WinSCP. Improve this answer. Martin Prikryl Martin Prikryl k 46 46 gold badges silver badges bronze badges. I've changed your answer to the accepted answer as I've learned a lot from it and for all the efford you've put in it!
Thanks again! Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. Close ;. GetRequestStream ; requestStream.
Write buffer, 0, buffer. Length ; requestStream. GetResponse ; Console. StatusDescription ; response. Your email address will not be published. Skip to content November 26, Summary of the article: What is FTP? For this we need to include the following namespace in the class: using System. Close ; writeStream. Rename; ftpRequest. GetResponse ; ftpResponse. You might also like. August 25, September 28, February 20, September 28, December 16, September 27, Thanks for comments.
Hi i am using above code, but i am facing error. The data can then be read using a StreamReader. The flexibility of this object will allow you to do lots of things with the response.
You can write the stream anywhere. For this example, I have written it to a standard string. You may change this depending on the data format. When dealing with code like this, I always aim for two things. Clean code with minimal lines while also remaining performant and easy to read. Using statements in C is very useful for ticking all boxes.
0コメント