Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default local file download

    I'm trying to download a local file from the server.
    Went I get the save dialog box and save the file, its
    saving the current aspx page and not the file I
    specified. Here is the code I"m using. Any ideas why
    this is happening?

    Response.ContentType = "application/x-zip-compressed";
    System.IO.FileStream downloadFile = new
    System.IO.FileStream
    (@"C:\\VirtualCafeSourceSafeCode\\Database.zip",
    System.IO.FileMode.Open);
    long FileSize;
    FileSize = downloadFile.Length;
    byte[] getContent = new byte[(int)FileSize];
    downloadFile.Read(getContent, 0, (int)
    downloadFile.Length);
    downloadFile.Close();
    Response.BinaryWrite(getContent);
    dsoltesz Guest

  2. Similar Questions and Discussions

    1. Problem with local file and local link
      Hi to everybody, I have installed a new version of flash player (9,0,28,0) and when I open a local file like: c:\test\index.html When I click...
    2. LWP - multipart/form-data file upload from scalar rather than local file
      I'm looking to do an HTTP upload, preferably with HTTP::Request::Common, but get the file data from either a filehandle or a scalar rather than...
    3. Need to download data to local access database
      Have a web app (ASP classic) that saves data to an Access database on the web host. Need to come up with some sort of ASP admin tool that will...
    4. Download binary file to local hard drive
      If this is not the appropriate NG, please help me by telling me where I should post this question. I want to keep a collection of Word Documents...
    5. Protect local data files from download?
      Just make sure that the extension of the file is unkown to IIS. Give the file a name like data.xyz or something. Then IIS will never serve it up...
  3. #2

    Default Re: local file download

    Are you sure it's saving an aspx page, or is it saving the zip file with the
    same name as the aspx page? The second would be expected.

    HTH,

    Kevin Spencer
    Microsoft FrontPage MVP
    Internet Developer
    [url]http://www.takempis.com[/url]
    Big things are made up of
    lots of Little things.

    "dsoltesz" <dan_soltesz@hotmail.com> wrote in message
    news:038001c33f56$cdc430b0$a501280a@phx.gbl...
    > I'm trying to download a local file from the server.
    > Went I get the save dialog box and save the file, its
    > saving the current aspx page and not the file I
    > specified. Here is the code I"m using. Any ideas why
    > this is happening?
    >
    > Response.ContentType = "application/x-zip-compressed";
    > System.IO.FileStream downloadFile = new
    > System.IO.FileStream
    > (@"C:\\VirtualCafeSourceSafeCode\\Database.zip",
    > System.IO.FileMode.Open);
    > long FileSize;
    > FileSize = downloadFile.Length;
    > byte[] getContent = new byte[(int)FileSize];
    > downloadFile.Read(getContent, 0, (int)
    > downloadFile.Length);
    > downloadFile.Close();
    > Response.BinaryWrite(getContent);

    Kevin Spencer Guest

  4. #3

    Default Re: local file download

    That would do it.

    HTH,

    Kevin Spencer
    Microsoft FrontPage MVP
    Internet Developer
    [url]http://www.takempis.com[/url]
    Big things are made up of
    lots of Little things.

    "dsoltesz" <dan_soltesz@hotmail.com> wrote in message
    news:039e01c33f59$200fc710$a501280a@phx.gbl...
    > I need to add this line of code in to make it work.
    > Response.AddHeader("content-
    > disposition", "filename=Database.zip");
    >
    >
    > >-----Original Message-----
    > >I'm trying to download a local file from the server.
    > >Went I get the save dialog box and save the file, its
    > >saving the current aspx page and not the file I
    > >specified. Here is the code I"m using. Any ideas why
    > >this is happening?
    > >
    > >Response.ContentType = "application/x-zip-compressed";
    > >System.IO.FileStream downloadFile = new
    > >System.IO.FileStream
    > >(@"C:\\VirtualCafeSourceSafeCode\\Database.zip" ,
    > >System.IO.FileMode.Open);
    > >long FileSize;
    > >FileSize = downloadFile.Length;
    > >byte[] getContent = new byte[(int)FileSize];
    > >downloadFile.Read(getContent, 0, (int)
    > >downloadFile.Length);
    > >downloadFile.Close();
    > >Response.BinaryWrite(getContent);
    > >.
    > >

    Kevin Spencer Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139