Ejemplo n.º 1
0
        private void handleFileGetRequest(FileGetRequest fgr, Connection client)
        {
            var fgResp = new FileGetResponse(fgr, null);

            try
            {
                var fileListing = ListLocalFiles();
                var targetFile  = fileListing.FirstOrDefault(f =>
                                                             f.FileName == fgr.FileToGet.FileName && f.Directory == fgr.FileToGet.Directory);
                if (targetFile == null)
                {
                    throw new FileNotFoundException("File does not exist on server");
                }
                fgResp.Data = File.ReadAllBytes(Path.Combine(_rootDir, targetFile.Directory, targetFile.FileName));
            }
            catch (Exception ex)
            {
                fgResp.Exception = ex;
            }
            finally
            {
                client.SendMessage(fgResp);
            }
        }
 public FileGetResponse(FileGetRequest request, byte[] data)
     : base(request)
 {
     FileToGet = request.FileToGet;
     Data      = data;
 }