using System; using System.IO; using Laserfiche.RepositoryAccess; namespace RA_Export_File_Memory_Stream { internal class Export_Ms { #region Variables globales private static readonly string Server = ""; private static readonly string Repository = ""; private static readonly string Login = ""; private static readonly string Password = ""; #endregion static void Main() { Session _Sess = null; int LF_ID = 72158; try { _Sess = new Session(); _Sess.LogIn(Login, Password, new RepositoryRegistration(Server, Repository)); // Retrieve document by ID DocumentInfo doc = Entry.TryGetEntryInfo(LF_ID, _Sess) as DocumentInfo; if (doc != null) { string mimeType = ""; string sOut = string.Format(@"C:\temp\{0}.{1}", doc.Name, doc.Extension); using (FileStream fileStream = File.Create(sOut)) { using (LaserficheReadStream edocStream = doc.ReadEdoc(out mimeType)) { // MemoryStream msTream = new MemoryStream(); //edocStream.CopyTo(msTream); edocStream.CopyTo(fileStream); } } Console.WriteLine("Done ---> " + sOut); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { if (_Sess != null) { _Sess.LogOut(); _Sess.Close(); } } } } }