473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 9396
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.