Hey all,
I posted few days back about displaying all .jpeg files inside a folder in a table...I figured out partially how to do that with JSP..By Partially I mean that I am able to count the number of files inside the folder, and then run a For loop based on the number of files..But now the problem is if I directly hardcode the name of the image say 1.jpg it displys that file for how many ever times the loop is running...
For example my folder has 2 images 1.jpg and 2.jpg..the name of the folder is pictures inside C drive..the code below counts the number of files in pictures folder, which is nothing but 2..then runs the loop for 2 times...As you can see, I have directly given the name of the img source as 1.jpg..That makes the 1.jpg to appear twice on my webpage..But now how do I make it dynamic and make both the image files appear(rather than 1.jpg appearing twice, I want 1.jpg and 2.jpg appear once each)??Should I do this
<img src="pictures/<%j;%>.jpg" width="242"/> Any help wud be appreciated..
<table>
<% string dir = @"C:pictures\\1870";
string[] files;
int files_count,count;
files =System.IO.Directory.GetFiles(dir);
files_count = files.Length;
string next = (files_count + 1) + ".jpg";
count = files_count;
//TextBox1.Text = dir;
for (int j = 1; j <= count; j++)
{
%>
<tr>
<td>
<img src[B]="pictures/1.jpg"[/B]width="242"/></td>
</tr>
<% }%>
</table>
Thanks
Ani