Save file from the Server to User's Desktop

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to save a file to an end users desktop from the Server on the
click of a button. This works when run the application on my local but does
not work when the application is running on the web server because Dim
copyfiletodesktop As String = "C:\temp\" points to the Web server’s C drive
and not the end users C while when I run the application on my desktop, C
points to my C Drive and that is why it works.

Does anyone know how I can change this line of code to point to end users
(external) Desktop and get to file to their desktops no matter their computer
setup?
Please Note that I know how to change it to "C:\Documents and
Settings\myprofilename\Desktop\" but the problem is this will not work for
everyone since I don't know their profile name and is not the best way to do
it.

Thanks for your help.
EC.
 
You cant - its restricted by sandbox security. The best you can do is start
a binary donwload from an asp.net page and hope the user accepts it.

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
Hello John,

Thanks for your help. I have resolved it by adding the following code below:

Dim myFile As FileInfo = New FileInfo(strFileNamePath)

Response.Clear()

'now we send the file header minus the resources extension.

Response.AddHeader("Content-Disposition", "attachment; filename=" &
Replace(myFile.Name, ".resources", ""))

Response.AddHeader("Content-Length", myFile.Length.ToString())

Response.ContentType = "application/octet-stream"

Response.WriteFile(myFile.FullName)

Response.End()

Thanks,
EC
 
glad your all sorted :)

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
Back
Top