Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 22nd, 2005, 07:40 AM
Authorized User
 
Join Date: Mar 2005
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default save a file on client machine

Hi

   I want to save an XML file on client machine with the facility of browsing the save dialog box. All this happen on the click of a button.

     plz guide me...

  #2 (permalink)  
Old March 30th, 2005, 05:52 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You can't actually do this. (Security issue.)
But you can create a link that performs a download. It is a bit complicated, because you cannot force a browser to obey you, and it might try to just display the file instead, depending on the settings of the user's machine.

Using VB 6 and IIS, this is what I do in response to a link click
on <a href="http://MySvr/MyApp.asp?wci=Send_File>Download File</a>


Code:
Private Sub Send_File_Respond()

    On Error GoTo Er

    Dim pth    As String
    Dim strDoc As String
    Dim CntTyp As String
    Dim fSize  As String
    Dim oStrm  As ADODB.Stream

    strDoc = "StandardMaterials.txt"
    CntTyp = "text/plain"

    pth = " . . . " ' Whatever you need here
    Set oStrm = New ADODB.Stream
    fSize = GetFileSize(pth & strDoc)

    Response.Buffer = True      ' Turning on buffering & clearing ensures that
    Response.Clear              ' all of the header information will be at the
                                ' top.  Feature of IIS 4 and on.
    oStrm.Open
    oStrm.Type = adTypeBinary
    oStrm.LoadFromFile pth & strDoc

    Response.AddHeader "Content-Disposition", "attachment; filename=" & strDoc
    Response.AddHeader "Content-Length", fSize
    Response.ContentType = CntTyp
    Response.Charset = "UTF-8"

    Response.BinaryWrite oStrm.Read
    Response.Flush

    oStrm.Close
    Set oStrm = Nothing

Rs: Exit Sub

Er: ' Report or log the error here, if there is one... 
    Resume Rs

End Sub
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to save files on client machine. Udi ASP.NET 1.0 and 1.1 Professional 3 January 22nd, 2007 11:26 AM
Saving DataSet data on client machine in .csv file balesh ASP.NET 1.0 and 1.1 Professional 0 October 25th, 2006 06:17 AM
Saving file on client machine balesh ASP.NET 1.0 and 1.1 Professional 1 September 18th, 2006 07:49 AM
Can't able to Open Word File in Client Machine senthilavs Classic ASP Basics 1 June 10th, 2006 01:02 PM
wirting file to web client machine from webserver paranthaman .NET Framework 2.0 0 February 25th, 2006 01:44 AM



All times are GMT -4. The time now is 01:52 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.