Hello,
You can use ASHX file (say, downloadfile.ashx) and use the following code (not tested, but it will be something like that) in it:
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=abc.txt");
Response.WriteFile(Server.MapPath("\\servername\folder1\folder2\folder3\abc.txt"));
Response.End();
and then use this in your anchor tag like:
<a href="downloadfile.ashx" target=""_blank"">Click me</a>
Note: You can also pass parameters for downloading different files like:
<a href="downloadfile.ashx?file=abc.txt" target=""_blank"">Click me</a>
and then, in ashx file, use the file name to download the appropriate file.
Then, replace your following code
Response.Write("<br>" + file);
by something like this
Response.Write("<br><a href="downloadfile.ashx?file=" + file + "">" + file + "</a>");</pre>
You'll maybe need to change your filepath from absolute to relative.
Hope it helps ;)