469,358 Members | 1,611 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

Save file from the Server to User's Desktop

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

Jul 22 '05 #1
3 9093
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

"EC" <EC@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
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.

Jul 22 '05 #2
EC
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
"John Timney (ASP.NET MVP)" wrote:
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

"EC" <EC@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
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.


Jul 25 '05 #3
glad your all sorted :)

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director

"EC" <EC@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
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
"John Timney (ASP.NET MVP)" wrote:
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

"EC" <EC@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
>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.
>


Jul 25 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by kieran | last post: by
4 posts views Thread by sunilj20 | last post: by
2 posts views Thread by Scott M. Lyon | last post: by
4 posts views Thread by Jonny | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.