你要说清楚你的要求,有没有具体的限制,如无,只要服务器上有sql server,连上服务器的sql server,调用扩展存储过程:xp_dirtree,就能获取服务器的文件列表

解决方案 »

  1.   

    这里是一个为某个目录中的文件生成缩略图的程序代码,应该对你有帮助。它列出了指定目录下的所有的文件:using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.IO;namespace DayOfDeveloper
    {
        public class ThumbnailGenerator : System.Web.UI.Page
        {
            private void Page_Load(object sender, System.EventArgs e)
            {
                String _path = Server.MapPath("images/");
                if ( !_path.EndsWith(@"\") )
                    _path += @"\";            DirectoryInfo _di = new DirectoryInfo(_path);
                FileInfo[] _fi = _di.GetFiles("*.jpg");            foreach ( FileInfo _f in  _fi)
                {
                    if ( !_f.Name.StartsWith("thumb_") )
                    {
                        String _imgName = _f.Name;
                
                        System.Drawing.Image _img = System.Drawing.Image.FromFile(_path + _imgName);                    if ( _img.Height > 72 )
                        {
                            Int32 _height = _img.Height;
                            Int32 _width = _img.Width;
                
                            Bitmap _imgOutput;
                            Double _dif;                        _dif = Convert.ToDouble(Decimal.Divide(_width,_height));
                            _width = Convert.ToInt32(Math.Ceiling(72 * _dif));
                            _imgOutput = new Bitmap(_img, _width, 72);
                            _img.Dispose();                        try
                            {
                                _imgOutput.Save(_path + "thumb_" + _imgName.ToLower(), System.Drawing.Imaging.ImageFormat.Jpeg);
                                _imgOutput.Dispose();
                                Response.Write("thumb_" + _imgName.ToLower() + " Saved</b><br>");
                            }
                            catch ( Exception _ex )
                            {
                                Response.Write("<b>Error Saving File</b><br>");
                                Response.Write(_ex.Message);
                                Response.Write("<br>");
                                Response.Write(_ex.StackTrace);
                                Response.Write("<br>");
                            }
                        }
                    }
                }
            }        #region Web Form Designer generated code
            override protected void OnInit(EventArgs e)
            {
                //
                // CODEGEN: This call is required by the ASP.NET Web Form Designer.
                //
                InitializeComponent();
                base.OnInit(e);
            }
            
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {    
                this.Load += new System.EventHandler(this.Page_Load);
            }
            #endregion
        }
    }