title: sending httpresponses in library file c#
body: <p>i used the following code to download the file folder in asp.net website are</p>
  
  <pre><code> string path = @"E:\sample.zip";
          FileInfo file = new FileInfo(path);
             int len = (int)file.Length, bytes;
               Response.ContentType = "text/html";  
            // Response.AddHeader "Content-Disposition", "attachment;filename=" + filename; 
               Response.AppendHeader("content-length", len.ToString());
             byte[] buffer = new byte[1024];
  
          using(Stream stream = File.OpenRead(path)) {
      while (len &gt; 0 &amp;&amp; (bytes =
          stream.Read(buffer, 0, buffer.Length)) &gt; 0)
      {
          Response.OutputStream.Write(buffer, 0, bytes);
          len -= bytes;
      }
  }
  </code></pre>
  
  <p>it works fine/...</p>
  
  <p>but my problem is when i used the same code to the library file as</p>
  
  <pre><code>FileInfo file = new FileInfo(ZipPath);
              int len = (int)file.Length, bytes;
              HttpResponse Response = new HttpResponse(TextWriter.Null);
              Response.ContentType = "text/html";
              Response.AppendHeader("content-length", len.ToString());
              byte[] buffer = new byte[1024];
  
              using (Stream stream = File.OpenRead(ZipPath))
              {
                  while (len &gt; 0 &amp;&amp; (bytes =
                      stream.Read(buffer, 0, buffer.Length)) &gt; 0)
                  {
                      Response.OutputStream.Write(buffer, 0, bytes);
                      len -= bytes;
                  }
              }
          }
  </code></pre>
  
  <p>it throws me a error as</p>
  
  <p><strong>OutputStream is not available when a custom TextWriter is used.</strong></p>
  
  <p>i guess the problem is in that line </p>
  
  <pre><code> HttpResponse Response = new HttpResponse(TextWriter.Null);
  </code></pre>
  
  <p>can you provide me a solution </p>
  
  <p>waiting for your responses....</p>