谢谢回复!!!

解决方案 »

  1.   

    openFileDialog 使用参看
    http://singlepine.cnblogs.com/articles/255772.html允许上传的扩展名,参看
    http://singlepine.cnblogs.com/articles/256023.htmlpublic static bool IsAllowedExtension(HtmlInputFile hifile)
    {
                string strOldFilePath = "",strExtension = "";            //允许上传的扩展名,可以改成从配置文件中读出
                string[] arrExtension = {".gif",".jpg",".jpeg",".bmp",".png"};            if(hifile.PostedFile.FileName != string.Empty)
                {
                    strOldFilePath = hifile.PostedFile.FileName;
                    //取得上传文件的扩展名
                    strExtension = strOldFilePath.Substring(strOldFilePath.LastIndexOf("."));
                    //判断该扩展名是否合法
                    for(int i = 0; i< arrExtension.Length; i++)
                    {
                        if(strExtension.Equals(arrExtension[i]))
                        {
                            return true;
                        }
                    }
                }        
                return false;
    }