Hi,
I am developing a website. I have a folder containing some images.
I have display list in gried view but on gried_itemcomannd download the image but following erroe are display
i have trying the following code

string filePath = "http://sdokannad.org/httpdocs/SDOKannad/DailyEntry/" + e.Item.Cells[12].Text;
                Response.AddHeader("Content-Disposition", "attachment;filename=\"" + e.Item.Cells[12].Text);
                Response.TransmitFile(filePath);
                Response.End();

http:/sdokannad.org/httpdocs/SDOKannad/DailyEntry/20150409_125733' is not a valid virtual path.

Please somebody help me with the code so that the users can download the folder when they click on the download button.

string[] filePaths = Directory.GetFiles(Server.MapPath("~/Images/"));
        List<ListItem> files = new List<ListItem>();
        foreach (string filePath in filePaths)
        {
            string fileName = Path.GetFileName(filePath);
            files.Add(new ListItem(fileName, "~/Images/" + fileName));
        }
        GridView1.DataSource = files;
        GridView1.DataBind();

For more info click here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.