public byte[] GetBytes(string path)
{
FileStream fs=null;
BinaryReader br=null;
try
{
byte[] buffer = null;
fs = new FileStream(Server.MapPath(path), FileMode.Open, FileAccess.Read);
br = new BinaryReader(fs);
long numBytes = new FileInfo(Server.MapPath(path)).Length;
buffer = br.ReadBytes((int)numBytes);
br.Close();
fs.Close();
return buffer;
}
catch (Exception err)
{
throw new Exception("SaveFileIntoDatabase: " + err.Message);
}
}
byte[] fileData = GetBytes(tempFilename);