问题:如何读取thumbs.db里的缩略图?
请先到这里下载一个控件
ThumbDBLib
A C# library for reading thumbs.db file
http://www.petedavis.net/MySite/DynPageView.aspx?pageid=31
引用dll,这里提供了 VB和C#代码,一个Thumbs.aspx,添加一个ID为 plcThumbs 的 PlaceHolder
<!-- {cps..0}-->
VB主要代码:
<!-- {cps..1}--> Dim ThumbDb As String = Server.MapPath( " . " ) & " /thumbs.db "
If System.IO.File.Exists(ThumbDb) Then
Dim ThumbLib As New ThumbDBLib.ThumbDB(ThumbDb)
If Not Request.QueryString( " thumb " ) Is Nothing Then
Dim Thumb As String = Request.QueryString( " thumb " )
Dim ThumbData As Byte () = ThumbLib.GetThumbData(Thumb)
Response.Clear()
Response.ContentType = " image/ " & System.IO.Path.GetExtension(Thumb).ToLower.Replace( " . " , "" )
Response.BinaryWrite(ThumbData)
Response.Flush()
Response.End()
Else
For Each thumb As String In ThumbLib.GetThumbfiles
If System.IO.File.Exists(Server.MapPath( " . " ) & " / " & thumb) Then
' CoulduseaLiteralcontrolhereifyouwantmore
' controloverthehtml.
Dim ThumbImage As New System.Web.UI.WebControls.Image
ThumbImage.ImageUrl = " thumbs.aspx?thumb= " & Server.UrlEncode(thumb)
ThumbImage.ImageAlign = ImageAlign.Top
ThumbImage.AlternateText = thumb
ThumbImage.BorderStyle = BorderStyle.Outset
ThumbImage.BorderWidth = New Unit( 1 )
ThumbImage.Attributes.Add( " hspace " , " 4 " )
ThumbImage.Attributes.Add( " vspace " , " 4 " )
ThumbImage.Attributes.Add( " onclick " , " window.location.href=' " & thumb & " '; " )
ThumbImage.Style.Add( " cursor " , " hand " )
plcThumbs.Controls.Add(ThumbImage)
End If
Next
End If
ThumbLib = Nothing
Else
Response.Write( " Thumbs.dbNotFound! " )
End If
C#主要代码:
浏览效果如图:
完毕。
源码可以在
这里
下载
更多文章、技术交流、商务合作、联系博主
微信扫码或搜索:z360901061
微信扫一扫加我为好友
QQ号联系: 360901061
您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。
【本文对您有帮助就好】元