private bool DownloadFileAction(string servarpath,string localpath,ServiceInfo client) { try { bool issuccess = false; string message = ""; Stream filestream = new MemoryStream(); long filesize = client.DownloadFile(servarpath, out issuccess, out message, out filestream); if (issuccess) { byte[] buffer = new byte[filesize]; FileStream fs = new FileStream(localpath, FileMode.Create, FileAccess.Write); int count = 0; while ((count = filestream.Read(buffer, 0, buffer.Length)) > 0) { fs.Write(buffer, 0, count); } fs.Flush(); fs.Close(); } else { MessageBox.Show(message); } } catch(Exception e) { MessageBox.Show(e.Message); return false; } return true; }