Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. About downloading file

About downloading file

Scheduled Pinned Locked Moved C#
tutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tauras81
    wrote on last edited by
    #1

    Hi, I am using this code for downloading a file.Can anybody tell how to use it without showing save as option:- Response.ContentType = "text/pdf"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + ViewState["Name"].ToString() + ".pdf"); Thread.Sleep(5000); Response.TransmitFile(sfilepath); Response.End(); Thanks

    N A 2 Replies Last reply
    0
    • T tauras81

      Hi, I am using this code for downloading a file.Can anybody tell how to use it without showing save as option:- Response.ContentType = "text/pdf"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + ViewState["Name"].ToString() + ".pdf"); Thread.Sleep(5000); Response.TransmitFile(sfilepath); Response.End(); Thanks

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      tauras81 wrote:

      without showing save as option:-

      That is not possible as it is controlled by the browser.

      Navaneeth How to use google | Ask smart questions

      1 Reply Last reply
      0
      • T tauras81

        Hi, I am using this code for downloading a file.Can anybody tell how to use it without showing save as option:- Response.ContentType = "text/pdf"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + ViewState["Name"].ToString() + ".pdf"); Thread.Sleep(5000); Response.TransmitFile(sfilepath); Response.End(); Thanks

        A Offline
        A Offline
        ashok_rgm
        wrote on last edited by
        #3

        Hello, u can try out with DownloadFile() method. for this u need to include namspace System.Net then u can try out as WebClient objWebClient = new WebClient(); objWebClient.DownloadFile(URI, targetfilename); Check this hope it helps Regards, ashok

        ashok

        S 1 Reply Last reply
        0
        • A ashok_rgm

          Hello, u can try out with DownloadFile() method. for this u need to include namspace System.Net then u can try out as WebClient objWebClient = new WebClient(); objWebClient.DownloadFile(URI, targetfilename); Check this hope it helps Regards, ashok

          ashok

          S Offline
          S Offline
          Shyam K Pananghat
          wrote on last edited by
          #4

          I think the above solution will solve your problem only when you are using this in a windows application.where webclient will act as intermediate browser and handle the request and target filename will be obviously a local path in your system to which you will be having access. :) But if the requirement is like you have to host the webapp in a remote server and the you are accessing this website from a different client machine, there would be no choice and will be entirely controlled by the browser which you use :(

          Shyam my blog dotnetscoups.blogspot.com . swthoughts.blogspot.com .

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups