Link to home
Start Free TrialLog in
Avatar of 1jaws
1jawsFlag for United States of America

asked on

download file

I have this code below that gets the folder and the file name from directory ok... now, I need user to be able to download the file wherever they wish to download on their pc... so, what I need to do next?

string folder = Server.MapPath("/emailAttachments/" + lblattachment.Text.ToString());
            string[] filePaths = Directory.GetFiles(folder);
            string result = Path.GetFileName(filePaths[0]);
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

System.IO.File.Copy ( result, "<path and name of the destination file on the user machine>" );

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ravi Vaddadi
Ravi Vaddadi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 1jaws

ASKER

James, yours doesnt work... SriVaddadi, I got this error..

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near 'PK'.
Avatar of 1jaws

ASKER

I do that code inside the ItemCommand(object sender, DetailsViewCommandEventArgs e)  for LinkButton clicked....
Hope you could resolve the error or let me know