Monday, March 12, 2012
Save any file into a table
I have a asp.net application where i can choose to save any file(could be jpg or dat or txt or xml etc etc) into a table.So far,i've manage to save it into an SQL server table in a column(set to Image datatype).But when i get the data from the table,put it into a byte array and recreate it.I notice that the files can be recreated correctly if they are of type .txt files.But jpg files can't be recreated and trying to open the jpg files gives an error.I don't think it is the file saving that is the problem since any files can be save.Rather it is the file recreating that is the problem.Can anyone help?Are you specifying the ContentType for the page?|||Yup,the content type is saved into the table as a seperate column too.As i need to return the results of the sql statement getting the data,content type,name etc in a dataset.I using ascii encoding to code the hex data(the file itself) into a string,insert it into a dataset and pass it back.The problem is after i get the string(which is actually hex data encoded into a string).How do i recreate the file data from the string?My guess is that i need to convert the string to hex,then to binary and do a binary write?Where do i set the content type anyway since i don't think writing it to response is correct.|||Thw worst part is that this is a console application and i can't figure out how to get hold of the contenttype property before writing my file from my table.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment