SAPIWS_Sample.SAPIWSWrapper.ReadFile C# (CSharp) Method

ReadFile() public method

public ReadFile ( string FileToRead, bool isDisplayErrorsGUI ) : byte[]
FileToRead string
isDisplayErrorsGUI bool
return byte[]
        public byte[] ReadFile(string FileToRead, bool isDisplayErrorsGUI)
        {
            byte[] Buf = null;

            try
            {
                FileStream f = File.OpenRead (FileToRead);
                Buf = new byte[f.Length];
                f.Read (Buf, 0, (int)f.Length);
                f.Close();
            }
            catch (Exception ex)
            {
                if (isDisplayErrorsGUI)
                    MessageBox.Show("Error reading the input file.\n\nException:\n" + ex.Message, "Error");
                return null;
            }

            return Buf;
        }