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. saving files from database

saving files from database

Scheduled Pinned Locked Moved C#
databasehelpquestion
8 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.
  • I Offline
    I Offline
    Icarus123
    wrote on last edited by
    #1

    Hi there. I have saved an MS word file to my database. I retrieve the following fields when accessing the DB: byte[], filename, extension I now want to, in code behind, open an "Download to" window, where i can save the file on my local machine. P.S i dont just save word files... i want to save any type of file. Can anyone help me with the problem?

    V 1 Reply Last reply
    0
    • I Icarus123

      Hi there. I have saved an MS word file to my database. I retrieve the following fields when accessing the DB: byte[], filename, extension I now want to, in code behind, open an "Download to" window, where i can save the file on my local machine. P.S i dont just save word files... i want to save any type of file. Can anyone help me with the problem?

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      Did you look at Response.WriteFile?

      Vasudevan Deepak Kumar Personal Homepage
      Tech Gossips
      A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson

      I 1 Reply Last reply
      0
      • V Vasudevan Deepak Kumar

        Did you look at Response.WriteFile?

        Vasudevan Deepak Kumar Personal Homepage
        Tech Gossips
        A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson

        I Offline
        I Offline
        Icarus123
        wrote on last edited by
        #3

        no, but how would you integrate the fields with Response.WriteFile

        C 1 Reply Last reply
        0
        • I Icarus123

          no, but how would you integrate the fields with Response.WriteFile

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

          Basically, you set the header to say you're downloading the file, and then stuff the bytes of the file into there. You should ask ASP.NET questions in the ASP.NET forum BTW.

          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 )

          I 1 Reply Last reply
          0
          • C Christian Graus

            Basically, you set the header to say you're downloading the file, and then stuff the bytes of the file into there. You should ask ASP.NET questions in the ASP.NET forum BTW.

            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 )

            I Offline
            I Offline
            Icarus123
            wrote on last edited by
            #5

            it is a bit unclear, what header are you talking about? "you set the header to say you're downloading the file". could you give me an example of this? Sorry about the "Not being in an asp forum"..

            N C 2 Replies Last reply
            0
            • I Icarus123

              it is a bit unclear, what header are you talking about? "you set the header to say you're downloading the file". could you give me an example of this? Sorry about the "Not being in an asp forum"..

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

              Icarus123 wrote:

              it is a bit unclear, what header are you talking about?

              He would be talking about HTTP headers.

              Icarus123 wrote:

              could you give me an example of this?

              Google[^]

              All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

              I 1 Reply Last reply
              0
              • I Icarus123

                it is a bit unclear, what header are you talking about? "you set the header to say you're downloading the file". could you give me an example of this? Sorry about the "Not being in an asp forum"..

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

                Response.ContentType="application/zip"; Response.AddHeader( "content-disposition","attachment; filename="+filename); Response.BinaryWrite(byteArray); Response.End(); That will cause whatever you want, to be written to the browser so the user downloads it.

                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
                • N N a v a n e e t h

                  Icarus123 wrote:

                  it is a bit unclear, what header are you talking about?

                  He would be talking about HTTP headers.

                  Icarus123 wrote:

                  could you give me an example of this?

                  Google[^]

                  All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

                  I Offline
                  I Offline
                  Icarus123
                  wrote on last edited by
                  #8

                  thanks for the example. one last question, because the file has no path, only byte[], how would i populate the FileInfo, so that i can use that information in the headers and WriteFile?

                  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