标题:把数据库中的图片读入到内存中.
只看楼主
04soft
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2006-6-17
 问题点数:0 回复次数:0 
把数据库中的图片读入到内存中.

读取图片文件到内存

Dim buff As Byte() = 样张字段的值 'Rows里的索引号根据您的要求改

' 在PictureBox中显示

' If buff.Length > 0 Then

Dim ms As New IO.MemoryStream(buff)

ms.Position = 0

PictureBox1.Image = System.Drawing.Image.FromStream(ms)

===

‘启动文件

Dim psInfo As New System.Diagnostics.ProcessStartInfo(d:\ww.txt)

psInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal

Dim myProcess As Process = System.Diagnostics.Process.Start(psInfo)

读取文本文件

Public Function loadfile(ByVal filename As String) As String

Dim enc As Encoding

Dim file As FileStream = New FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read)

If file.CanSeek Then

Dim bom(3) As Byte

file.Read(bom, 0, 4)

If ((bom(0) = &HEF And bom(1) = &HBB And bom(2) = &HBF) Or (bom(0) = &HFF And bom(1) = &HFE) Or (bom(0) = &HFE And bom(1) = &HFF) Or (bom(0) = 0 And bom(1) = 0 And bom(2) = &HFE And bom(3) = &HFF)) Then ‘判断是否是UNICODE字符集

enc = Encoding.Unicode

Else

enc = Encoding.Default

End If

file.Seek(0, SeekOrigin.Begin)

Else

enc = Encoding.Default

End If

Dim filebyte(file.Length) As Byte

file.Read(filebyte, 0, file.Length)

'转成系统对应的编码字符()

Dim myencoder As Encoding = enc

file.Close()

file = Nothing

Return New String(myencoder.GetChars(filebyte))

End Function

搜索更多相关主题的帖子: 内存 数据库 
2006-06-18 10:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-73112-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.046219 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved