Tuesday, 31 May 2016

Creating download link to a file on a file server

For .Net Developer This Might Help You For Creating 
download link to a file on a file server

string strURL;
strURL = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "AllFiles\Log\") + "SaleLogFile.log";//name of the file you are picking 
         

            WebClient req = new WebClient();
            HttpResponse response = HttpContext.Current.Response;
            response.Clear();
            response.ClearContent();
            response.ClearHeaders();
            response.Buffer = true;
            response.AddHeader("Content-Disposition", "attachment;filename='SaleLogFile.log'");//change downloaded file name
            byte[] data = req.DownloadData(strURL);
            response.BinaryWrite(data);
            response.End();

No comments:

Post a Comment

Print Only Grid View in ASP.net

ASP.net How to Print Only GridView < div id ="gridviewDiv" >   < asp:GridView ID ="gridViewToPri...