So what I've tried to do is download multiple files in a directory on a FTP Server into a Local Directory, I've figured out how to download just one file, but I don't know how to download multiple files.
FtpWebRequest request =
(FtpWebRequest)WebRequest.Create(ip.Text + "/mods/");
request.Credentials = new NetworkCredential(user.Text, pass.Text);
request.Method = WebRequestMethods.Ftp.DownloadFile;
using (Stream ftpStream = request.GetResponse().GetResponseStream())
using (Stream fileStream = File.Create(directory.Text + @"\mods\"))
{
byte[] buffer = new byte[10240];
int read;
while ((read = ftpStream.Read(buffer, 0, buffer.Length)) > 0)
{
fileStream.Write(buffer, 0, read);
Console.WriteLine("Downloaded {0} bytes", fileStream.Position);
}
Whenever I use just the /mods/
directory, I get a error that says WebClient Exception
.
Whenever I use /mods/example_file.txt
it successfully downloads.
So my Goal with all this is, how can I download the entire /mods/
directory to my computer.
I have searched the internet and read multiple posts and I cannot seem to figure this out.
I am also a beginner in C# so most likely I am doing something wrong.