Avatar of mburk1968
Flag for United States of America

asked on 

ftpwebrequest Help C#

I can compile this code and run it without issue in Visual Studio. However where is it saving the file that it downloads if indeed it is actually downloading a file?

using System;
using System.IO;
using System.Net;
using System.Text;

namespace Examples.System.Net
    public class WebRequestGetExample
        public static void Main()
            // Get the object used to communicate with the server.
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://mysite.net/site/wwwroot/ftp/Export.csv");
            request.Method = WebRequestMethods.Ftp.DownloadFile;

            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = new NetworkCredential("Username\\$username", "password");

            FtpWebResponse response = (FtpWebResponse)request.GetResponse();

            Stream responseStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(responseStream);

            Console.WriteLine("Download Complete, status {0}", response.StatusDescription);


Open in new window

C#.NET Programming

Avatar of undefined
Last Comment
Fernando Soto

8/22/2022 - Mon