protected void RadGrid1_OnItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) { try { //filepath to be changed if (e.CommandName == "FileName") { GridDataItem item = e.Item as GridDataItem; string strFileName = item.GetDataKeyValue("File Name").ToString(); Response.ContentType = "APPLICATION/OCTET-STREAM"; System.String disHeader = "Attachment; Filename=\"" + strFileName + "\""; Response.AppendHeader("Content-Disposition", disHeader); // transfer the file byte-by-byte to the response object GridDataItem parentItem = e.Item.OwnerTableView.ParentItem; string strFolderName = parentItem.GetDataKeyValue("Folder Name").ToString(); string strFolderPath = System.IO.Path.Combine(DashLiteConstants.Pages.ArchivedCaptFilesPage.ArchivedFilesPath, strFolderName); string strFilePath = System.IO.Path.Combine(strFolderPath, strFileName); System.IO.FileInfo fileToDownload = new System.IO.FileInfo(strFilePath); Response.Flush(); Response.WriteFile(fileToDownload.FullName); Response.End(); } } catch (Exception ex) { Response.Write(ex.Message); //throw; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)