简体   繁体   English

Asp.net查找和下载文件

[英]Asp.net finding and downloading file

I have File Upload form which users use to upload certain files on the server. 我有“文件上传”表单,用户可使用该表单上传服务器上的某些文件。 The files are uploaded in path that look like this. 文件将按照以下路径上传。

"G:\\VS\\Ticketing System2\\UploadedFiles\\" + ProjectId + "\\" + ticketId + "\\TicketFiles\\";

After that I have a repeater which displays some data and have a hyperlink. 之后,我有一个中继器,该中继器显示一些数据并具有超链接。 I want to name the hyperlink "Download files(" + fileCount + ")" and onclicked it should display a regular Save As window. 我想将超链接命名为"Download files(" + fileCount + ")"然后单击它应显示常规的“另存为”窗口。 Can you give me some code to do that. 你能给我一些代码做到这一点吗? I've never done something like this. 我从来没有做过这样的事情。

To get the number of files in the directory, you need to use IO. 要获取目录中的文件数,您需要使用IO。 Then 然后

string path = @"G:\\VS\\Ticketing System2\\UploadedFiles\\" + ProjectId + "\\" + ticketId + "\\TicketFiles\\";
int numFiles = Directory.GetFiles(path).Length;

Then in your page_load, just change to .Text of the link to include the numFiles variable 然后在您的page_load中,只需将链接的.Text更改为包含numFiles变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM