遍历目录下所有图片文件显示的方法.(已废弃)
2006-06-27 14:41
671 查看
protected void Page_Init(object sender, EventArgs e)
{
this.Imgpre.ImageUrl = "../images/title/0.gif";
string[] fileentries;
fileentries = Directory.GetFiles(Server.MapPath("~/flyxnews/images/title"));
int j = fileentries.Length;
string[] filenames = new string[j];
for (int i = 0; i < j; i++)
{
filenames[i] = Path.GetFileName(fileentries[i]);
}
for (int i = 0; i < j; i++)
{
this.Panelimgchoose.Controls.Add(imgchosse(filenames)[i]);
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
//图片选择框函数
public ImageButton[] imgchosse(string[] filenames)
{
int j = filenames.Length;
ImageButton[] img = new ImageButton[j];
for (int i = 0; i < j; i++)
{
string imgid = filenames[i].Replace(".gif", "");
img[i] = new ImageButton();
img[i].ID = imgid;
img[i].ToolTip = "请点击选择";
img[i].AlternateText = "尝试贴图,可耻地失败鸟";
img[i].CssClass = "postimg";
img[i].BorderStyle = BorderStyle.Outset;
img[i].BorderWidth = 2;
string imgurl = "../images/title/" + filenames[i];
img[i].Height = 50;
img[i].Width = 50;
img[i].ImageUrl = imgurl;
img[i].Click += new ImageClickEventHandler(this.imgs_Click);
}
return img;
}
protected void imgs_Click(object sender, ImageClickEventArgs e)
{
this.Imgpre.ImageUrl = ((ImageButton)sender).ImageUrl;
}
}
{
this.Imgpre.ImageUrl = "../images/title/0.gif";
string[] fileentries;
fileentries = Directory.GetFiles(Server.MapPath("~/flyxnews/images/title"));
int j = fileentries.Length;
string[] filenames = new string[j];
for (int i = 0; i < j; i++)
{
filenames[i] = Path.GetFileName(fileentries[i]);
}
for (int i = 0; i < j; i++)
{
this.Panelimgchoose.Controls.Add(imgchosse(filenames)[i]);
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
//图片选择框函数
public ImageButton[] imgchosse(string[] filenames)
{
int j = filenames.Length;
ImageButton[] img = new ImageButton[j];
for (int i = 0; i < j; i++)
{
string imgid = filenames[i].Replace(".gif", "");
img[i] = new ImageButton();
img[i].ID = imgid;
img[i].ToolTip = "请点击选择";
img[i].AlternateText = "尝试贴图,可耻地失败鸟";
img[i].CssClass = "postimg";
img[i].BorderStyle = BorderStyle.Outset;
img[i].BorderWidth = 2;
string imgurl = "../images/title/" + filenames[i];
img[i].Height = 50;
img[i].Width = 50;
img[i].ImageUrl = imgurl;
img[i].Click += new ImageClickEventHandler(this.imgs_Click);
}
return img;
}
protected void imgs_Click(object sender, ImageClickEventArgs e)
{
this.Imgpre.ImageUrl = ((ImageButton)sender).ImageUrl;
}
}
相关文章推荐
- PHP采用自定义函数实现遍历目录下所有文件的方法
- 遍历文件目录下所有图片并保存到统一路径
- js遍历本地所有图片文件,显示在浏览器中
- C#遍历指定目录下所有文件的方法
- PHP 遍历目录下的所有文件的方法
- 递归的一些方法使用:深度遍历路径中的所有文件和目录,删除一个有文件的文件夹
- Python遍历目录中的所有文件的方法
- 遍历显示文件夹下所有目录、所有文件的函数,没有分页
- 遍历显示文件夹下所有目录、所有文件的函数
- [PHP]PHP自定义遍历目录下所有文件的方法
- php 遍历显示文件夹下所有目录、所有文件的函数
- 用ASP,FSO显示当前根目录下所有文件,目录列表的方法
- Python遍历目录中的所有文件的方法
- 使用Shell遍历目录及其子目录中的所有文件方法
- js遍历本地所有图片文件,显示在浏览器中
- C#显示文件夹下所有图片文件的方法
- php 遍历显示文件夹下所有目录、所有文件的函数,没有分页的代码
- PHP采用自定义函数实现遍历目录下所有文件的方法
- 遍历某目录下的所有文件的方法
- 遍历指定目录下的图片文件 显示在gridview 并添加点击事件