0

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.

2
Contributors
1
Reply
13
Views
2 Years
Discussion Span
Last Post by tarunap
0
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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.