I currently have a TreeView showing a directory in a web page. I don't think you can capture click events on a Node so instead I'm creating the navigation link to the same page which processes a parameter (path).
I've tried a couple things:
Response.ContentType = "text/txt";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.Write(file.ToString());
Response.End();
^^ The code above only really works for Text files (or whatever extension I want to define). ^^
The code below writes the file as a set of characters to the browser.
if (!IsPostBack)
{
string path = Request["path"];
if ((path != "") && (path != null))
{
Response.TransmitFile(path);
Response.End();
}
}
Is there a good solution to this I'm just missing? I need to send any file with an option to save it when selected from a TreeView.
Thanks in advance for your help!