Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 7th, 2005, 10:10 AM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default How to Manipulate Download Dlg

I have tried the code above the line, and below the line in the following Subroutine:
Code:
 Public Sub DownLoadResults(ByVal FileName As String, ByVal Rsp As HttpResponse)

    Dim f     As New FileStream(FileName, FileMode.Open)
    Dim fSize As Long = f.Length
    Dim Buffer(CInt(fSize)) As Byte

    f.Read(Buffer, 0, CInt(fSize))
    f.Close()

    Rsp.Buffer = True
    Rsp.Clear()
    Rsp.AppendHeader("Content-Disposition", "attachment; filename=" & FileName)
    Rsp.AppendHeader("Content-Length", fSize)

    Rsp.BinaryWrite(Buffer)
    Rsp.End()

   ' ————————————————————————————————————————————————————————————————————————————

    Dim f As New FileInfo(FileName)

    Rsp.Buffer = True
    Rsp.Clear()
    Rsp.AddHeader("Content-Disposition", "attachment; filename=" & FileName)
    Rsp.AddHeader("Content-Length", f.Length())

    Rsp.ContentType = "text/plain"              ' Set the appropriate ContentType.
    Rsp.Charset = "UTF-8"

    Rsp.WriteFile(FileName)                     ' Write the file directly to the
    Rsp.End()                                   ' HTTP output stream.

 End Sub
Both versions operate identically. (I switched to the first version—the part above the line—after getting undesirable results with the second version—the part below the line.)
In both cases, in the Save/Open/Cancel dialog that is presented for downloading the file, the message is:
Code:
  File name: wfv_view
  File Type:
  From:      localhost
“wfv_view” is the name of the .aspx page with the download link on it.
The link’s href is “http : // localhost/WF/wfv_view.aspx?Action=DownLoad” (but without the spaces...) The name of the file in FileName is like Temp002.txt, Temp003.txt, etc.
When I select to save the file, the “Save as [u]t</u>ype:” textbox says “HTML Document.”
If I change the file name to (for instance) Tmp.txt, what gets saved is Tmp.txt.aspx. I need to specify "Tmp.txt" (delineate with quotes) to get a file extension other than .aspx. In any event, the actual file itself—the contents, that is—gets saved properly.

This is [u]not</u> the results I had with very similar code in VB6.

How can I get the downloading functionality between .NET and Internet Explorer to present a “Save” dialog box with the actual filename, and with the appropriate extension type preselected?
Reply With Quote
Reply


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 Manipulate Download Dlg BrianWren Pro VB.NET 2002/2003 0 July 7th, 2005 10:26 AM
How to Manipulate Download Dlg BrianWren ASP.NET 1.x and 2.0 Application Design 0 July 7th, 2005 10:23 AM
manipulate recordset k2_andy Access VBA 1 May 30th, 2004 05:46 PM



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


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