Ouvrir fichier - telechargement
Code .NET SQL :: ASP.NET :: C# :: Import / Export data
Page 1 sur 1
Ouvrir fichier - telechargement
- Code:
protected void LinkButtonDocOnClick(object sender, EventArgs e)
{
string path = string.Empty;
string filename = ((LinkButton)sender).Text;
if (!string.IsNullOrEmpty(((LinkButton)sender).CommandArgument))
path = ApplicationManager.UploadFile + "\\" + ((LinkButton)sender).CommandArgument;
if (System.IO.File.Exists(path))
{
System.IO.FileInfo file = new System.IO.FileInfo(path);
Response.Clear(); // clear the current output content from the buffer
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
Response.AppendHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}
}
Ou
- Code:
string path = HttpContext.Current.Server.MapPath("~") +"\\"+ ApplicationManager.UploadDocumentFile + "\\" + filename;
Code .NET SQL :: ASP.NET :: C# :: Import / Export data
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum