I am working on a script that loops through the image directory looking for images. I have the following code and it displays all of the images just fine, However, how can I limit the files to display?
For example what if I want to display just the images that start with 'abc'?
abc1.jpg
abc2.jp
abc3.jpg
etc. etc.
[code]
foreach(FileInfo file in files)
{
blah...
blah...
}
[/code]
Thanks in advance.Maybe this can be of some help:
private void Button1_Click(object sender, System.EventArgs e)
{
if(this.TextBox1.Text.Trim() == "")
{
Response.Write("Please enter a search critera");
return;
}string crit = this.TextBox1.Text.Trim();
string files = "";DirectoryInfo di = new DirectoryInfo(@."C:\myImageFolder");
foreach(FileInfo fi in di.GetFiles(crit + "*.*"))
{
files += "<li>" + fi.Name;
}this.Label1.Text = files;
}
That works!
Thank you!
0 comments:
Post a Comment