FtpWebRequest - multiple file upload
C#
1
Posts
1
Posters
0
Views
1
Watching
-
I use the following code for a single file upload
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create("ftp://servername/filename.txt");
ftp.Credentials = new NetworkCredential("login", "password");
ftp.Method = WebRequestMethods.Ftp.UploadFile;
StreamWriter sw = new StreamWriter(ftp.GetRequestStream());
sw.Write(fileContent);
sw.Close();Now - how do I upload multiple files in a single connection? Calling FtpWebRequset.Create with a different file name erases all the info about credentials, method etc. so I must set these again, which is annoying, but I suppose that the connection must be established again, which is not only annoying but also ineffective. Is there any better way?