问题描述
Hi
i将字符串转换为byte []如下:
我的字符串是图像代码:
byte [] attachment = Convert.FromBase64String(my string);
我在二进制字段中保存sql server中的附件。
当我想要的时候在Windows中运行此文件,我无法在Windows照片查看器中看到图像。
i以这种方式运行文件:
附件AttObj = MyDB.Attachment.Where(a => a.AttachmentId == ID).First();
if(AttObj.Attachment1 != null)
{
流程proc =新流程();
string FileTmpDircetion =目录。 CreateDirectory(我的临时目录);
FileTmpDircetion = System.IO.File.WriteAllBytes(FileTmpDircetion,AttOb.file);
proc。 StartInfo.FileName = FileTmpDircetion;
proc.StartInfo.UseShellExecute = true;
proc.Start();
}
s请注意:
Windows照片浏览器无法打开此图片,因为该文件似乎已损坏,损坏或太大
请帮帮我
Hii convert a string to byte[] as following:
my string is a image code:
byte[] attachment = Convert.FromBase64String(my string);
I save attachment in sql server in a binary field.
when i want to run this file in windows , i cant see image in windows photo viewer.
i run file in this way:
Attachment AttObj = MyDB.Attachment.Where(a => a.AttachmentId == ID).First();
if (AttObj.Attachment1 != null)
{
Process proc = new Process();
string FileTmpDircetion = Directory.CreateDirectory(my temp directory);
FileTmpDircetion = System.IO.File.WriteAllBytes(FileTmpDircetion, AttOb.file);
proc.StartInfo.FileName = FileTmpDircetion ;
proc.StartInfo.UseShellExecute = true;
proc.Start();
}
it shows a message that :
"Windows photo viewr cant open this picture because the file appears to be damaged,corrupted or too large"
please help me
这篇关于如何运行存储在Sql中的二进制数据字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!