Solved

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

Posted on 2009-04-02
2
598 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

717 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