- public static byte[] ConvertFileToByte(string fileName)
- {
- if (!System.IO.File.Exists(fileName))
- {
- return null;
- }
- System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open,System.IO.FileAccess.Read,FileShare.ReadWrite);
- byte[] nowByte = new byte[(int)fs.Length];
- try
- {
- fs.Read(nowByte, 0, (int)fs.Length);
- return nowByte;
- }
- catch (Exception)
- {
- return null;
- }
- finally
- {
- fs.Close();
- }
- }