Top Ad unit 728 × 90

random

Get Bytes from files in .net

 public static byte[] GetBytesFromFile(this string PhysicalFilePath)
        {
            FileStream stream = null;
            byte[] buffer;
            try
            {
                stream = File.OpenRead(PhysicalFilePath);
                buffer = new byte[stream.Length];
                stream.Read(buffer, 0, Convert.ToInt32(stream.Length));
            }
            catch
            {
                buffer = new byte[0];
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                    stream.Dispose();
                }
            }
            return buffer;
        }



Get Bytes from files in .net Reviewed by Vikas Kumar Singh on December 03, 2017 Rating: 5

No comments:

All Rights Reserved by DotNetBasic.com © 2019

Contact Form

Name

Email *

Message *

© 2018 All rights reserved by DotNetBasic. Powered by Blogger.