System.IO.File.ReadAllBytes C# (CSharp) Méthode

ReadAllBytes() private méthode

private ReadAllBytes ( String path ) : byte[]
path String
Résultat byte[]
        public static byte[] ReadAllBytes(String path)
        {
            return InternalReadAllBytes(path);
        }

Same methods

File::ReadAllBytes ( string path ) : byte[]

Usage Example

Exemple #1
0
        public ChaperoneFormModel GetChaperoneFormModel(long eventCustomerId)
        {
            var chaperoneSignature = _chaperoneSignatureRepository.GetByEventCustomerId(eventCustomerId);

            var staffSignatureFile = chaperoneSignature != null?_fileRepository.GetById(chaperoneSignature.StaffSignatureFileId) : null;

            if (staffSignatureFile == null)
            {
                return(new ChaperoneFormModel
                {
                    EventCustomerId = eventCustomerId,
                    CustomerAnswers = null,
                    PatientSignatureBytes = null,
                });
            }

            var chaperoneQuestions = _chaperoneQuestionRepository.GetAllQuestions();

            var chaperoneAnswers = _chaperoneAnswerRepository.GetByEventCustomerId(eventCustomerId);

            var eventCustomer = _eventCustomerRepository.GetById(eventCustomerId);

            var mediaLocation = _mediaRepository.GetChaperoneSignatureLocation(eventCustomer.EventId, eventCustomer.CustomerId);

            string signatureFilePath = string.Empty;

            var signatureFile = chaperoneSignature != null && chaperoneSignature.SignatureFileId.HasValue ? _fileRepository.GetById(chaperoneSignature.SignatureFileId.Value) : null;

            if (signatureFile != null)
            {
                signatureFilePath = Path.Combine(mediaLocation.PhysicalPath, signatureFile.Path);
            }

            var staffSignatureFilePath = Path.Combine(mediaLocation.PhysicalPath, staffSignatureFile.Path);

            var chaperoneFormModel = new ChaperoneFormModel();

            chaperoneFormModel.EventCustomerId = eventCustomerId;
            chaperoneFormModel.CustomerAnswers = chaperoneAnswers
                                                 .Select(x => new ChaperoneAnswerModel
            {
                QuestionId = x.QuestionId,
                Answer     = x.Answer
            })
                                                 .ToArray();

            if (!string.IsNullOrEmpty(signatureFilePath) && File.Exists(signatureFilePath))
            {
                var signatureFileByte = File.ReadAllBytes(signatureFilePath);
                chaperoneFormModel.PatientSignatureBytes = Convert.ToBase64String(signatureFileByte);
            }

            if (File.Exists(staffSignatureFilePath))
            {
                var staffSignatureFileByte = File.ReadAllBytes(staffSignatureFilePath);
                chaperoneFormModel.StaffSignatureBytes = Convert.ToBase64String(staffSignatureFileByte);
            }

            return(chaperoneFormModel);
        }
All Usage Examples Of System.IO.File::ReadAllBytes