显示图片时 不能够获取正确 的 路径if((System.IO.Path.GetExtension(entry.Name)=="gif") || (System.IO.Path.GetExtension(entry.Name)
显示图片时 不能够获取正确 的 路径if((System.IO.Path.GetExtension(entry.Name)=="gif") || (System.IO.Path.GetExtension(entry.Name)=="jpg"))总是检测几个根目录下的 bin 等,不能 检测 images 目录 ,和根目录下的文件
void ListImages()
{
//initialize control
imageOutput.Controls.Clear();
string strUploadPath = Request.QueryString["UploadPath"];
string strDirectory = Server.MapPath("~/"+ strUploadPath);
DirectoryInfo dir = new DirectoryInfo( strDirectory );
foreach ( FileSystemInfo entry in dir.GetFileSystemInfos() )
{
if((System.IO.Path.GetExtension(entry.Name)=="gif") || (System.IO.Path.GetExtension(entry.Name)=="jpg"))
{
HtmlImage image1 = new HtmlImage();
image1.Src = "/" + strUploadPath + "/" + entry.Name;
image1.Height=100;
image1.Border=1;
image1.Attributes.Add("onclick","javascript:window.returnValue ='" + strUploadPath + "/" + entry.Name +"';" +" window.close();");
imageOutput.Controls.Add(image1);
}
}
}