TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
toanhoi bui
NA
70
207.1k
Show all image in Folder on Server
Sep 14 2011 8:48 AM
Hello everybody, I want to show all image in Folder on Server by using Image control. I using a string array to save all file name and when I click button "show", the image is showed on Image control by
order.
Here my code.
//String array to save filename
public string[] nfile=new string[100];
int i ;
int j;//to show by order
protected void Button3_Click(object sender, EventArgs e)
{
//Load all image to string array
i = 0;
btnNext.Enabled = true;
foreach (string file in Directory.GetFiles(Server.MapPath("Sample") + "\\", "*.jpg"))
{
string namefile = file.Remove(0, 60);//"d:\DZHosts\LocalUser\toanhoi\www.buiductoan.somee.com\Sample\","");
namefile.Trim();//namefile="a.jpg"
nfile[i] = namefile;
i++;
}
j = 0;
}
//Button show
if (j <= i)
{
ImgView.ImageUrl ="~/Sample" + nfile[j];
j++;
}
But If I click show button, nfile array wil return null.I don't understand.Can you help me to fix?
Reply
Answers (
1
)
Convert datatable into list
Validations to web site