Results 1 to 6 of 6

Thread: Load files

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    Load files

    Hi,

    Im new to asp.net.I need to load several files from a web site.
    My type of files are ppt, doc, xls files. I have made a search on the forum and thanks to Menhdak I found this

    VB Code:
    1. if System.IO.File.Exists(Server.MapPath("createdfiles/woof.txt")) Then
    2.  
    3.         Dim TargetFile As New System.IO.FileInfo(Server.MapPath("createdfiles/woof.txt"))
    4.  
    5.         ' clear the current output content from the buffer
    6.         Response.Clear()
    7.         ' add the header that specifies the default filename for the Download/
    8.         ' SaveAs dialog
    9.         Response.AddHeader("Content-Disposition", "attachment; filename=" + _
    10.             TargetFile.Name)
    11.         ' add the header that specifies the file size, so that the browser
    12.         ' can show the download progress
    13.         Response.AddHeader("Content-Length", TargetFile.Length.ToString())
    14.         ' specify that the response is a stream that cannot be read by the
    15.         ' client and must be downloaded
    16.         Response.ContentType = "application/octet-stream"
    17.         ' send the file stream to the client
    18.         Response.WriteFile(TargetFile.FullName)
    19.         ' stop the execution of this page
    20.         Response.End()
    21.  
    22. End If

    I replaced "createdfiles/woof.txt" and put in "mytext.doc" but this does not work. At the moment my file is in the bin. Obviously later on it will be on the server. can someone please help me with this. This is the first time Im loading a webs site. Also pls tell where i put the file and how to set its path in the code. Many many thanks
    Many thanks
    Last edited by angelica; Dec 25th, 2006 at 05:40 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width