0
I am wanting to download a.exe file from my FTP server, but there is a part of the code that is giving me trouble.
Error: Invalid expression term while (CS1525)
someone can tell me what’s wrong?
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri(serverPath));
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential(userName, userPassword);
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader sr = new StreamReader(responseStream);
FileStream fs = File.Create(destinationFile + @"\app.exe");
byte[] buffer = new byte[32 * 1024];
int read;
sr.Read(while ((read = sr.Read(buffer,0,buffer.Length)) > 0)
{
fs.Write(buffer, 0, read);
}
Your answer solved the while problem, but since you said my code doesn’t make sense '-' it pointed out other errors, do you know how I can download a.exe file from my FTP server? I am hours looking for a solution and I can’t find.
– Paulo Ricardo
@Pauloaleixo I don’t know if this is exactly what you want, but in the old days I used the following code to check software updates and download them.
– Francisco
I think not, I’ll give solved because solved the problem with the while.
– Paulo Ricardo