怎样使用LINQ技术来保存或显示图片文件?.
(C#)怎样通过LINQ进行Image类型的字段操作,如保存到数据库、从数据库取出并显示等,请高人指点!
------解决方案--------------------
正好遇到这个问题,
存储文件
Dim m As New DbLib.sys_version
'------
'数据:version
m.ver = version.Text
'数据:备注
m.bz = bz.Text
For i As Integer = 0 To Me.ds.Tables(1).Rows.Count - 1
Dim f As New DbLib.sys_filelist
f.ver = Me.version.Text
f.mc = Me.ds.Tables(1).Rows(i)("mc")
f.Item = Nothing
'获取文件路径
Dim path As String = ds.Tables(1).Rows(i)("item")
Dim fs As New IO.FileStream(path, IO.FileMode.Open, IO.FileAccess.Read)
Dim bt(fs.Length) As Byte
fs.Read(bt, 0, fs.Length)
fs.Close()
fs = Nothing
f.Item = bt
f.ismust = 1
’存储
m.sys_filelists.Add(f)
Next
db.sys_versions.InsertOnSubmit(m)
‘提交更新
db.SubmitChanges()
’获取文件
Dim ver = From p In db.sys_versions Where p.ver > CDec(input) Select p
If ver.Count = 1 Then
MessageBox.Show("发现升级版本,点击确认按钮开始更新程序!", "系统提示", MessageBoxButtons.OK)
'清除目录
Dim uppath As String = Application.StartupPath + "\up\"
Try
System.IO.Directory.Delete(uppath, True)
Catch
End Try
IO.Directory.CreateDirectory(uppath)
Dim up = From p In db.sys_versions
Dim ff As New DbLib.sys_version
ff = up.ToList.Item(0)
For Each a As DbLib.sys_filelist In ff.sys_filelists
Dim aa() As Byte = a.Item.ToArray
Dim ms As New IO.MemoryStream(aa)
Dim fs As New IO.FileStream(uppath + a.mc, IO.FileMode.CreateNew)
Dim bw As New IO.BinaryWriter(fs)
For i As Integer = 0 To aa.Length - 1
bw.Write(aa(i))
Next i
bw.Close()
fs.Close()
ms.Close()
Next
System.IO.File.Delete(verpath)
Dim sw As IO.StreamWriter = IO.File.CreateText(verpath)
sw.WriteLine(ff.ver)
sw.Flush()
sw.Close()
‘启动程序
End If