using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Com.FirmLib.Common
{
    public class PostFile
    {
        public byte[] GetBytes(string filePath)
        {
            if (!File.Exists(filePath))
                return null;
            byte[] c = null;
            using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                BinaryReader br = new BinaryReader(fs);
                c = br.ReadBytes((int)fs.Length);
            }
              
            return c;
        }

        public string GetString(string filePath, Encoding encoding)
        {
            var bytes = GetBytes(filePath);
            if (bytes == null)
                return string.Empty;
            return encoding.GetString(bytes);
        }
    }
}
