1

i have a server image control the id is Picoftheday and i was trying to generate a url for that image control.. here is my image url generating code.....

private string PicID()
    {
        DataTable dt = new DataTable();
        Connection dbconn = new Connection();
        SqlDataAdapter ad = new SqlDataAdapter();
        SqlCommand cmd = new SqlCommand();
        cmd.CommandText = "select top(1) picture_ID from t_picture order by Picture_UploadDate desc";
        ad.SelectCommand = cmd;
        cmd.Connection = dbconn.DBConnection;
        ad.Fill(dt);
        string value = null;
        foreach (DataRow dr in dt.Rows)
        {
            value = dr[0].ToString();

        }
        string url = Server.MapPath("..\\ArchievedPic\\Thumbnail\\");
        string[] files = Directory.GetFiles(@url, "" + value + ".*");
       // string url = files[0].ToString();
        string money = files[0].ToString();
        return money;
    }

on page load ....

protected void Page_Load(object sender, EventArgs e)
    {
        Picoftheday.ImageUrl = PicID();
    }

can anyone help please..

1 Answer 1

1

MapPath needs a tilde that represents the root directory of the asp application:

string url = Server.MapPath("~\\ArchievedPic\\Thumbnail\\");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.