BlogEngine.Core.Providers.UNCFileSystemProvider.FileToByteArray C# (CSharp) Method

FileToByteArray() private static method

Converts a file path to a byte array for handler processing
private static FileToByteArray ( string FilePath ) : byte[]
FilePath string the file path to process
return byte[]
        private static byte[] FileToByteArray(string FilePath)
        {
            byte[] Buffer = null;

            try
            {
                System.IO.FileStream FileStream = new System.IO.FileStream(FilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
                System.IO.BinaryReader BinaryReader = new System.IO.BinaryReader(FileStream);
                long TotalBytes = new System.IO.FileInfo(FilePath).Length;
                Buffer = BinaryReader.ReadBytes((Int32)TotalBytes);
                FileStream.Close();
                FileStream.Dispose();
                BinaryReader.Close();
            }
            catch (Exception ex)
            {
                Utils.Log("File Provider FileToByArray", ex);
            }

            return Buffer;
        }