Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9206095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:06:12+00:00 2026-06-18T00:06:12+00:00

I have a web application that generates excel files from a template. When the

  • 0

I have a web application that generates excel files from a template.

When the new file is streamed to the client I deleted the file. This works fine in my computer, but for whatever reason, when accesing the website from another computer, the file is deleted before streamed to the client, so the file is always empty (0 bytes)
Here is the code:

try
{
  Response.Clear();
  Response.ClearHeaders();
  Response.ContentType = "application/ms-excel";
  Response.AddHeader("content-disposition", "attachment;filename=" + newFN + ".xlsx");                            
  Response.TransmitFile(DestFile);
  Response.Flush();
  Response.End();
}
finally
{
  File.Delete(DestFile);
}

Why this works fine from my computer, and it doesn’t from another computer?

What can I do to delete generated files and when? I’m thinking in having like a schedule task, to check by date, all files before specific date, and delete them, but is there any other solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:06:13+00:00Added an answer on June 18, 2026 at 12:06 am

    The following works for me:

    Response.Clear();
    Response.ClearHeaders();
    Response.ContentType = "application/ms-excel";
    Response.AddHeader("content-disposition", "attachment;filename=" + newFN + ".xlsx");                            
    Response.TransmitFile(DestFile);
    Response.Flush();
    File.Delete(DestFile);
    HttpContext.Current.ApplicationInstance.CompleteRequest();
    

    But you should consider use the Response.BinaryWrite method if the file is being generated dinamically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have JSF web application that generates XLS file and gives user link to
I have a web application that generates two different Excel reports with different numbers
I have a java web application that generates and displays graphical pictures based upon
I have a web application that generates enlarged images of smaller images uploaded by
I have a legacy application that generates VRML 1.0 files. I'd like to build
I have a web application A which generates config files for another application B.
I have this problem; I'm currently doing some modification on a web application that
I have a hosted web application that generates reports based on daily end of
I have this requirement where I must print a receipt from a Web Application.
I have a web application that allows users to enter search criteria and the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.