Opening a binary document from db is failing
-
Hi, I am downloading a binary document from sql server and depending upon my file extn it should either open doc txt or image.For txt it is working fine while for word it is saying"Word experience an error in opening the file".While for jpg image viewer is opening but no image is there What could be the reason I am using windows application in C#
Looks like your file is not getting downloaded completely. Post some code here - maybe someone can help you.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick - Silverlight *.XCP files
-
Looks like your file is not getting downloaded completely. Post some code here - maybe someone can help you.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it. My latest tip/trick - Silverlight *.XCP files
if (dt.Rows.Count > 0) { result = (byte[])dt.Rows[0].ItemArray[0]; filetype = (String)dt.Rows[0].ItemArray[1]; } String new_FileName = Path.ChangeExtension(Path.GetTempFileName(),filetype); File.WriteAllBytes(new_FileName, result); System.Diagnostics.Process.Start(new_FileName); THis is my code i will get bytes in result array and filetype also.SO depending on that I am opening the file to display the data
-
if (dt.Rows.Count > 0) { result = (byte[])dt.Rows[0].ItemArray[0]; filetype = (String)dt.Rows[0].ItemArray[1]; } String new_FileName = Path.ChangeExtension(Path.GetTempFileName(),filetype); File.WriteAllBytes(new_FileName, result); System.Diagnostics.Process.Start(new_FileName); THis is my code i will get bytes in result array and filetype also.SO depending on that I am opening the file to display the data
In my case the same is working properly but I am using
dt.rows(0)("FieldName")
instead ofItemarray
. May be there is problem while saving it into database. -
In my case the same is working properly but I am using
dt.rows(0)("FieldName")
instead ofItemarray
. May be there is problem while saving it into database. -
In my case the same is working properly but I am using
dt.rows(0)("FieldName")
instead ofItemarray
. May be there is problem while saving it into database. -
In my case the same is working properly but I am using
dt.rows(0)("FieldName")
instead ofItemarray
. May be there is problem while saving it into database. -
Hi, Instead of opening the binary data from db in a file is it possible to store this in a file in some locations given by the user. Like if my binary file is a doc file i should store that file in some location say c:\file.doc. seeism
What? you want to copy the file in a diff location? Just copy the file in a specified location using IO.File.Copy
-
What? you want to copy the file in a diff location? Just copy the file in a specified location using IO.File.Copy
Hi, I got the file in binary format from db.Now i want to save this file in some location given by the user by a file save as dialog option without opening it. String new_FileName = Path.ChangeExtension(Path.GetTempFileName(), filetype); File.WriteAllBytes(new_FileName, result); FileDialog fldlg = new SaveFileDialog(); fldlg.InitialDirectory = "c:\\";// @":D\"; fldlg.Filter = "*.jpg|*.gif|*.txt|*.doc|*.pdf|*.htm"; fldlg.FileName = filename; This is my code.I did like this But file is not saving
-
Hi, I got the file in binary format from db.Now i want to save this file in some location given by the user by a file save as dialog option without opening it. String new_FileName = Path.ChangeExtension(Path.GetTempFileName(), filetype); File.WriteAllBytes(new_FileName, result); FileDialog fldlg = new SaveFileDialog(); fldlg.InitialDirectory = "c:\\";// @":D\"; fldlg.Filter = "*.jpg|*.gif|*.txt|*.doc|*.pdf|*.htm"; fldlg.FileName = filename; This is my code.I did like this But file is not saving
What exactly you are trying to do? SaveFileDialog doesnt saves anything. It only shows the dialog box. You need to use
fldlg.ShowDialog
to show dialog and ask user to select a filename. Then you need to copy the file into its new location specified by user usingsystem.IO.File.Copy(new_FileName, fldlg.FileName)
or sort of. -
What exactly you are trying to do? SaveFileDialog doesnt saves anything. It only shows the dialog box. You need to use
fldlg.ShowDialog
to show dialog and ask user to select a filename. Then you need to copy the file into its new location specified by user usingsystem.IO.File.Copy(new_FileName, fldlg.FileName)
or sort of.