Solved

Receiving "Could not open file, sharing violation" error when streaming data file from ASP.NET website

Posted on 2009-04-02
2
597 Views
Last Modified: 2012-05-06
Hi,

I am attempting to stream data from a database, to a file.  Everything is working good, until you click "Open" on the browsers "Do you wish to open or save this file" dialog box.  When you click open, the browser appears to download the file, then the associated application tries to open the file, then I get the error attached.

I am not sure how to code this so that the file opens without a sharing violation.

This only happens in Internet Explorer (Version 7)
The file opens successfully in Firefox and Google Chrome.
var buffer = (byte[])dsData.Tables[0].Rows[0][0];
        Response.ContentType = "application/EDI.Document";
        Response.AddHeader("content-disposition", "attachment; filename=file.edi");
        Response.AddHeader("Content-Length", buffer.Length.ToString());
        Response.BinaryWrite(buffer);

Open in new window

error.JPG
0
Comment
Question by:kevinjd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
williamcampbell earned 500 total points
ID: 24054339
How big is the file? Over 4MB there may be a problem
Try a Response.End after the write and maybe a Response.Flush

Curios why it's trying to write file[2] .. is there one there already? Did a download succees? Are there two downloads occuring at the same time?

Few things to think about.


0
 

Author Comment

by:kevinjd
ID: 24054388
The file is under 1k.  786 bytes.

Every time I run this code to test, it downloads the file.  So each time, it appends a number on the temp file name, which is fine.

It seems IE is keeping the file locked for whatever reason.  As stated, this does not happen in Firefox/Chrome.  They both allow the file to be opened instantly.

The same thing happened after adding         Response.End();
        Response.Flush();


0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question