简体   繁体   中英

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. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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