`
king_c
  • 浏览: 213831 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

convert file into byte array

    博客分类:
  • c#
 
阅读更多

private byte [] StreamFile(string filename)
{
   FileStream fs = new FileStream(filename, FileMode.Open,FileAccess.Read);

   // Create a byte array of file stream length
   byte[] ImageData = new byte[fs.Length];

   //Read block of bytes from stream into the byte array
   fs.Read(ImageData,0,System.Convert.ToInt32(fs.Length));

   //Close the File Stream
   fs.Close();
   return ImageData; //return the byte data
}
 This function is used to convert file into byte array. some time we require to convert file into byte to save into database or send to other system using remoting.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics