public Stream dowlande(string authToken, string pathe, Node node) { //Create the DocumentManagement service client DocumentManagementClient docManClient = new DocumentManagementClient(); CWS.DocumentManagement.OTAuthentication otAuth = new CWS.DocumentManagement.OTAuthentication(); otAuth.AuthenticationToken = authToken; ContentServiceClient contentServiceClient = new ContentServiceClient(); CWS.ContentService.OTAuthentication otAuthConServices = new CWS.ContentService.OTAuthentication(); otAuthConServices.AuthenticationToken = authToken; //string fileName=null; string contextID = null; try { contextID = docManClient.GetVersionContentsContext(ref otAuth, node.ID, 0); } catch (FaultException e) { MessageBox.Show(e.Message); } finally { docManClient.Close(); } Stream downloadStream = null; try { downloadStream = contentServiceClient.DownloadContent(ref otAuthConServices, contextID); } catch (FaultException e) { MessageBox.Show(e.Message); } finally { contentServiceClient.Close(); } /*FileStream fileStream = null; * try * { * string path = Path.GetDirectoryName(Application.ExecutablePath).Replace(@"bin\Debug", string.Empty); * fileName = Path.Combine(path.Replace(@"bin\Debug", string.Empty), @"GED_image\" + node.Name + ".tif"); * if (File.Exists(fileName)) * { * File.Delete(fileName); * } * fileStream = new FileStream(fileName, FileMode.Create); * byte[] buffer = new byte[BUFFER_SIZE]; * long fileSize = 0; * for (int read = downloadStream.Read(buffer, 0, buffer.Length); read > 0; read = downloadStream.Read(buffer, 0, buffer.Length)) * { * fileStream.Write(buffer, 0, read); * fileSize += read; * } * } * catch (Exception e) * { * //MessageBox.Show(e.Message); * } * finally * { * if (fileStream != null) * { * fileStream.Close(); * } * downloadStream.Close(); * }*/ return(downloadStream); }