将文件转换成byte[]数组

/// <summary>
/// 将文件转换成byte[] 数组
/// </summary>
/// <param name="fileUrl">文件路径文件名称</param>
/// <returns>byte[]</returns>

protected byte[] AuthGetFileData(string fileUrl)
{
  using (FileStream fs = new FileStream(fileUrl, FileMode.OpenOrCreate, FileAccess.ReadWrite))
  {
    byte[] buffur = new byte[fs.Length];
    using (BinaryWriter bw = new BinaryWriter(fs))
    {
      bw.Write(buffur);
      bw.Close();
    }
    return buffur;
  }
}

猜你喜欢

转载自www.cnblogs.com/xsj1989/p/9803464.html