10inja
07-18-2009, 08:41 PM
Hi all.
hope this is the right place to post this.
I wanted to call a function that will search a subfolder and return the first file it finds.. how do I call this function from the web page? what's the correct format?
also, is that the right approach?
in the web page:
<asp:ImageID="Image2"runat="server"Width=250pxImageUrl="GetFirstImage("Testing")"/>
in the codebehind:
using System.IO;
public partialclass _Default : System.Web.UI.Page
{
private FileInfo[] rgFiles;
protected void Page_Load(object sender, EventArgs e)
{
}
public string GetFirstImage(string Stock)
{
DirectoryInfo di = newDirectoryInfo(HttpRuntime.AppDomainAppPath.ToSt ring() + "images\\" + Stock);
rgFiles = di.GetFiles("*.jpg");
return"~/images/" + Stock + "/" + rgFiles[0];
}
}
hope this is the right place to post this.
I wanted to call a function that will search a subfolder and return the first file it finds.. how do I call this function from the web page? what's the correct format?
also, is that the right approach?
in the web page:
<asp:ImageID="Image2"runat="server"Width=250pxImageUrl="GetFirstImage("Testing")"/>
in the codebehind:
using System.IO;
public partialclass _Default : System.Web.UI.Page
{
private FileInfo[] rgFiles;
protected void Page_Load(object sender, EventArgs e)
{
}
public string GetFirstImage(string Stock)
{
DirectoryInfo di = newDirectoryInfo(HttpRuntime.AppDomainAppPath.ToSt ring() + "images\\" + Stock);
rgFiles = di.GetFiles("*.jpg");
return"~/images/" + Stock + "/" + rgFiles[0];
}
}