C#读取thumbs.db文件中的缩略图

问题:C#如何读取thumbs.db里的缩略图?

需要下载一个控件

ThumbDBLib,A C# library for reading thumbs.db file

 

引用dll,Thumbs.aspx,添加一个ID为plcThumbsPlaceHolder 

<form  id ="form1"  runat ="server">  
 <div>  
       <asp:PlaceHolder  id ="plcThumbs"  runat ="server"  EnableViewState ="False" ></asp:PlaceHolder>  
     </div>  
      </form>  

 

C#主要代码:

    string  ThumbDb  =  Server.MapPath( " . " )  +   " //thumbs.db " ;  
                 if  (System.IO.File.Exists(ThumbDb))  
                 {  
                    ThumbDBLib.ThumbDB ThumbLib  =   new  ThumbDBLib.ThumbDB(ThumbDb);  
                     if  ((Request.QueryString[ " thumb " ]  !=   null ))  
                     {  
                         string  Thumb  =  Request.QueryString[ " thumb " ];  
                         byte [] ThumbData  =  ThumbLib.GetThumbData(Thumb);  
                        Response.Clear();  
                       Response.ContentType  =   " image/ "   +  System.IO.Path.GetExtension(Thumb).ToLower().Replace( " . " ,  "" );  
                       Response.BinaryWrite(ThumbData);  
                       Response.Flush();  
                       Response.End();  
                   }  
                    else  
                    {  
                        foreach  ( string  thumb  in  ThumbLib.GetThumbfiles())  
                        {  
                            if  (System.IO.File.Exists(Server.MapPath( " . " )  +   " // "   +  thumb))  
                            {  
                                //  Could use a Literal control here if you want more   
                                //  control over the html.  
                               System.Web.UI.WebControls.Image ThumbImage  =   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);  
                           }  
                       }  
                  }  
                  ThumbLib  =   null ;  
              }  
               else  
               {  
                 Response.Write( " Thumbs.db Not Found! " );  
              }// xt 和 image  数据类型。  

浏览效果如图:

 C#读取thumbs.db文件中的缩略图

源码:C#读取thumbs.db数据源代码下载

来源:http://blog.csdn.net/downmoon/article/details/4241315

加支付宝好友偷能量挖...


评论(0)网络
阅读(240)喜欢(0)Asp.Net/C#/WCF