Bhavesh Vankar

Bhavesh Vankar

  • 763
  • 1.1k
  • 86.9k

Convert webcam image into binary

Jan 21 2021 8:14 AM
when i capture image using webcam and try to store into binary format in sql server its not working i have tried below code. whats wrong ...?
kindly suggest me right way....
 
my image control name is vimage 
 
bold line is generating error "Empty path name is not legal."
 
my code is below
i have declare
  1. string _imagepath2 = vimage.imageurl;    
  2. public static byte[] ImageToBinary(string _imgpath2)    
  3. {    
  4.     FileStream fS = new FileStream(_imgpath2, FileMode.Open, FileAccess.Read);    
  5.     byte[] b = new byte[fS.Length];    
  6.     fS.Read(b, 0, (int)fS.Length);    
  7.     fS.Close();    
  8.     return b;    
  9. }  
Error Is
Empty path name is not legal.

Answers (11)