public long Read(Stream sOutput, string pathSourceFile) { using (var sInput = new FileStream(pathSourceFile, FileMode.Open, FileAccess.Read)) { EFS.CopyStream(sInput, sOutput); return(sInput.Length); } }
public long Write(Stream sInput, string pathDestFile) { using (var sOutput = new FileStream(pathDestFile, FileMode.CreateNew, FileAccess.Write)) { EFS.CopyStream(sInput, sOutput); return(sOutput.Length); } }
/// <summary>Copy a file from EFS to the specified System.Stream.</summary> /// <remarks>Unlike the rest of the code in this class, this method is safe to call from any thread.</remarks> /// <param name="sOutput"></param> /// <param name="idFile"></param> void CopyFileToStream(Stream sOutput, int idFile) { using (var s = pool.GetSession()) using (var trans = s.BeginTransaction()) { var e = EFS.byId(rs, idFile); if (null == e) { throw new FileNotFoundException(); } using (var sInput = e.data.Read(rs.cursor)) EFS.CopyStream(sInput, sOutput); } }