Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a web app that I download file via the browser using this code:

 

Response.Clear();

Response.AddHeader("Content-Disposition",

"attachment; filename=" + file.Name);

Response.AddHeader("Content-Length", file.Length.ToString());

 

Response.ContentType = "application/vnd.ms-excel";

 

Response.Flush();

Response.WriteFile(file.FullName);

Response.End();

 

 

 

This works fine when the file is not opened by someone; otherwise, if a user has the file open on his machine, the web app will not launch the writefile function stating "file is used by another process". Is there a way to launch the file in read-only even though the file is already launched on a local client pc? TIA.

Posted

They are trying to access the same file that the app downloads locally onto their local machine.

 

This is scenario may help:

1.) One User opens xls file on local machine.

2.) Another user clicks button on application to open same xls file

- App downloads xls file to local temporary files folder of local machine

3.) App does not load file because of this error "fiel is used by another process"

- This occurs when I try to WriteFile()

  • 2 years later...
Posted

Hi,

 

Did u find a solution to your problem? I have the same issue.

We have an asp.net UI to display log files (generated using log4net) to the user and the user can download the log file.

Response.WriteFile(FilePath); is used to download the file

 

If the log file is currently being written by a program then we are getting the error ""file is used by another process".

 

Any workarounds to this to be able to allow users to download the log files even though it is being currently written by another process ?

 

Thanks

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...