using (CAPDataDownloadWebservice aWS = new CAPDataDownloadWebservice()) try { FileResult aResult = aWS.Stream_LatestPackage(12345, "abcde", 123); if (!aResult.Success) MessageBox.Show(aResult.ErrMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); else using (FileStream aFile = new FileStream(@"d:\" + aResult.File.Name, FileMode.Create, FileAccess.Write)) foreach (byte[] aChunk in aResult.File.Chunk) aFile.Write(aChunk, 0, aChunk.Length); } catch (Exception E) { MessageBox.Show(E.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }