از این دو تا تابع می تونید استفاده کنید
protected static byte[] ReadFileToByteArray(string fileName)
{
FileStream fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Read);
long len;
len = fileStream.Length;
Byte[] fileAsByte = new Byte[len];
fileStream.Read(fileAsByte, 0, fileAsByte.Length);
MemoryStream memoryStream = new MemoryStream(fileAsByte);
return memoryStream.ToArray();
}
public void FileStoreToDataBase(byte[] content, string fileName)
{
SqlConnection con = new SqlConnection();
try
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlCommand insert = new SqlCommand("insert into table (data) values (@data)", con);
insert.Parameters.AddWithValue("data", content);
// data.Value = content;
insert.ExecuteNonQuery();
}
finally
{
con.Close();
}
}