I want to download an .exe file from my FTP server, but it has a part in the code that is giving me trouble.
Error: Invalid expression term 'while' (CS1525)
Can anyone 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);
}