Microsoft.Protocols.TestSuites.MS_LISTSWS.TestSuiteHelper.GetAttachmentContent C# (CSharp) Method

GetAttachmentContent() public static method

Get the content in the file of specified file name.
public static GetAttachmentContent ( string fileName ) : byte[]
fileName string The specified file name
return byte[]
        public static byte[] GetAttachmentContent(string fileName)
        {
            byte[] data = null;
            FileStream fs = null;
            try
            {
                fs = File.Open(fileName, FileMode.Open);
                int len = (int)fs.Length;
                data = new byte[len];
                fs.Read(data, 0, len);
            }
            catch (IOException exp)
            {
                testSite.Debug.Fail(ErrorMessageTemplate, "reading content in the file " + fileName, exp.InnerException);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }

            return data;
        }