472,782 Members | 1,307 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 software developers and data experts.

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 9362
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: palgrave | last post by:
Hi, How do you create an html link from a web page to a read-only excel spreadsheet without the browser asking if the user wants to open it or save it?
10
by: Dica | last post by:
i've got an app that needs to connect to sql server and login with a useName/password. currently, my app saves this info in an XML file in plain text (i.e. no encryption). everytime the app is...
8
by: kieran | last post by:
Hi, I want to download an image from the web and save it locally. I have spent all day messing about with this and am still no where. We have a firewall so i use the below code. I know it...
4
by: sunilj20 | last post by:
Hello, I have a requirement wherein, a user clicks on a file name in an ASP.NET web application, and the file should automatically be downloaded (Without showing the "Open", "Save As") in the...
2
by: Scott M. Lyon | last post by:
I'm working on a WinForm application, and recently was informed that I need to create an "Export" function for the data (stored in SQL Server), in a specific (TXT, tab delimited) format. I'd...
3
by: EC | last post by:
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...
4
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1 using VB.NET as the coding language TIA
1
by: pbrown | last post by:
Hi, I'm using VB.net 2003, and I have a problem. I need a way of saving a file directly to the desktop, without hardcoding the direct path to the desktop into the program. For example, I'm trying...
2
by: JPS | last post by:
We have a ASP.Net/SQL Server application that is used as a document management system. The documents are stored per project. The files are stored on a file server but we store the file name in the...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.