/* Upload */ /* ******************** */ #region Upload public void Upload(ReneCommunicatorFile request) { ReneServiceCallback guest = OperationContext.Current.GetCallbackChannel <ReneServiceCallback>(); string fileName = request.FileName; string uploadPath = request.FileDestination; string filePath = Path.Combine(Path.GetFullPath(uploadPath), fileName); FileStream fs = null; try { fs = File.Create(filePath); byte[] buffer = new byte[1024]; int read = 0; while ((read = request.Data.Read(buffer, 0, buffer.Length)) != 0) { fs.Write(buffer, 0, read); } } finally { if (fs != null) { fs.Close(); fs.Dispose(); } if (request.Data != null) { request.Data.Close(); request.Data.Dispose(); } } }
/* Download */ /* ******************** */ #region Download public ReneCommunicatorFile Download(ReneCommunicatorFileRequest request) { ReneServiceCallback guest = OperationContext.Current.GetCallbackChannel <ReneServiceCallback>(); ReneCommunicatorFile up = new ReneCommunicatorFile(); FileStream file = new FileStream("ApplicationInformation.xml", FileMode.Open, FileAccess.Read); up.Data = file; up.FileName = "ApplicationInformation3.xml"; up.FileDestination = ""; return(up); }