session101 Posted June 22, 2006 Posted June 22, 2006 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. Quote
Administrators PlausiblyDamp Posted June 22, 2006 Administrators Posted June 22, 2006 Not entirely sure where the problem lies? Are you getting the error because people are opening the .xls on their local machines or are they accessing the same .xls as the server is trying to download? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
session101 Posted June 22, 2006 Author Posted June 22, 2006 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() Quote
axsubram Posted December 18, 2008 Posted December 18, 2008 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.