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. Web Development
  3. ASP.NET
  4. How to download files??

How to download files??

Scheduled Pinned Locked Moved ASP.NET
csharptutorialquestion
6 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.
  • U Offline
    U Offline
    Uma Kameswari
    wrote on last edited by
    #1

    Hi, I am working on a web project which is allowing the users to upload their documents. And it should also provide the user with the option to dowlaod the documents that were uploaded by him. Documents can be of any type(work,excel,pdf etc even image files can be uploaded).Now my doubt is how to achieve the dowlaoding of the files that are stored. I am working on .net 2.0 Regards, Uma

    M H 2 Replies Last reply
    0
    • U Uma Kameswari

      Hi, I am working on a web project which is allowing the users to upload their documents. And it should also provide the user with the option to dowlaod the documents that were uploaded by him. Documents can be of any type(work,excel,pdf etc even image files can be uploaded).Now my doubt is how to achieve the dowlaoding of the files that are stored. I am working on .net 2.0 Regards, Uma

      M Offline
      M Offline
      meghamaharshi
      wrote on last edited by
      #2

      set navigateurl to physical address of that file

      U 1 Reply Last reply
      0
      • U Uma Kameswari

        Hi, I am working on a web project which is allowing the users to upload their documents. And it should also provide the user with the option to dowlaod the documents that were uploaded by him. Documents can be of any type(work,excel,pdf etc even image files can be uploaded).Now my doubt is how to achieve the dowlaoding of the files that are stored. I am working on .net 2.0 Regards, Uma

        H Offline
        H Offline
        hemant kaushal
        wrote on last edited by
        #3

        SqlCommand command = new SqlCommand("proc_GetImages", connection); command.CommandType = CommandType.StoredProcedure; SqlDataReader rd = command.ExecuteReader(); byte[] image = null; while (rd.Read()) { image = (byte[])rd[0]; str = rd[1].ToString(); //content type of file } rd.Close(); Response.ContentType=str ; Response.Buffer=true; Response.AddHeader("Content-Disposition", "attachment; filename=" + name + ";"); Response.AddHeader("Content-Length", image.Length.ToString()); Response.BinaryWrite(image); Response.End(); use this code to download file stored in database

        U 1 Reply Last reply
        0
        • M meghamaharshi

          set navigateurl to physical address of that file

          U Offline
          U Offline
          Uma Kameswari
          wrote on last edited by
          #4

          How will we set the navigate URL? Can you pls give me an example. I tried by setting the href of anchor tag. But for excels files it is not working.

          1 Reply Last reply
          0
          • H hemant kaushal

            SqlCommand command = new SqlCommand("proc_GetImages", connection); command.CommandType = CommandType.StoredProcedure; SqlDataReader rd = command.ExecuteReader(); byte[] image = null; while (rd.Read()) { image = (byte[])rd[0]; str = rd[1].ToString(); //content type of file } rd.Close(); Response.ContentType=str ; Response.Buffer=true; Response.AddHeader("Content-Disposition", "attachment; filename=" + name + ";"); Response.AddHeader("Content-Length", image.Length.ToString()); Response.BinaryWrite(image); Response.End(); use this code to download file stored in database

            U Offline
            U Offline
            Uma Kameswari
            wrote on last edited by
            #5

            Thank you but my file is stored on the hard disk. I am storing files on the server. Now I want to download them from the application.

            C 1 Reply Last reply
            0
            • U Uma Kameswari

              Thank you but my file is stored on the hard disk. I am storing files on the server. Now I want to download them from the application.

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Perhaps this will help: http://www.codeproject.com/KB/tips/HowToUseGoogle.aspx?msg=2458041#xx2458041xx[^] The person who answered you here has given you all the important information ( that is, how to use the response object to write a file back out for download ). In fact, what you want is simpler, you just need to read the file bytes from the file system.

              Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              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