如何使用C#和ASP.NET上的链接按钮上传和下载文件谢谢

问题描述:

how to upload and download a file using only a linkbutton on c# and asp.net thanks





我尝试了什么:



我是编程的新手,我需要一些帮助来只下载一个文件我已经完成了上传一些文件,但我无法使用linkbutton下载



What I have tried:

im new on the programming and i need some help to download only a file i already done uploading some file but i cant download using a linkbutton

创建一个指向您文件的超链接。
Create a hyperlink to your file.


引用:

我不知道如何使用linkbutton下载文件。

and i dont know how to download the file using the linkbutton.



LinkBut​​ton 就像一个普通的按钮, CSS 就像一个标签。

试试这个




LinkButton is like a normal button with CSS like an anchor Tag.
try this

protected void LinkButton1_Click(object sender, EventArgs e)
       {
           string filePath = "Your file path from the folder";
           Response.ContentType = ContentType;
           Response.AppendHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(filePath));
           Response.WriteFile(filePath);
           Response.End();
       }