I have a C# project connected to a SQL Server Database, and I' m doing a format recognition for file upload. More specifically, I upload files in varbinary and I store they in a column in the Db. When I download they, I want to recognize their format. I found on the web some hot keywords (or metadata) through which I could recognize if they are docx or xlsx or other. My problem is that if I do this on SQL:
select * from table where convert(varchar(8000),objectFile) like '%docprop%'`
it works and the db returns only word file. But if I want to do this on C# after taking the varbinary how can I do? I tried this but don' t work:
var item = context.tObject_M.SingleOrDefault(x => x.objectId == objectId);
var files = item.objectFile;
string filess = Convert.ToString(files);
byte[] itemi = item.objectFile;
string ciao = System.Text.Encoding.UTF8.GetString(itemi);
if (ciao.Contains("DOCPROPS"))
{
filess = "ciao";
}