Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 10th, 2005, 10:36 AM
Authorized User
 
Join Date: Dec 2003
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DolphinBay
Default The process cannot access the file...

Good morning to you all....

I am getting the following error after I upload a file through ASP.NET, and then try to delete it:

The process cannot access the file "530.gif" because it is being used by another process.

When I kill the aspnet_wp.exe process I once again have access to manipulate the file. I have scoured the Net to try and find a solution to no avail. Anyone have any ideas? Many thanks in advance. Please find the code below.

Regards,
Eric

'Compile new file name
Dim sNFile As String = Request.QueryString("cid") & Path.GetExtension(sPath)
Dim sNPath As String = cfg.setting("PHYSICAL_PATH") & "data\" & sNFile
'Save file to server
Try
newImg.PostedFile.SaveAs(sNPath)
Catch ex As Exception
tStatus.Text = ex.Message
End Try
newImg.Dispose()



Dolphin Bay, Inc. -- turning visions into eReality(tm) -- West Palm Beach, FL
Website Design, Internet Strategy, Search Engine Marketing

www.dphin.com
 
Old May 10th, 2005, 03:18 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I have experienced similar problems with a web application that reads images into stream readers and manipulates them. Despite thorough (at least what I though was thorough) closing and destruction of the objects used, IIS still held a lock on the files. Haven't solved it yet.

-Peter
 
Old May 10th, 2005, 03:30 PM
Authorized User
 
Join Date: Dec 2003
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DolphinBay
Default

Peter,

Thank you for your thoughts. I am trying to work around this problem by simply uploading the file to a directory on the server and pointing to the image through a standard <img> tag. Only the path is being stored in the DB.

Once the file has been uploaded via .NET, the file is "locked" and cannot be manipulated at all through .NET or manually via the OS itself. I am not creating any reader.

Do you know of any way to simply upload files without IIS hanging onto them?

Many thanks,
Eric


Dolphin Bay, Inc. -- turning visions into eReality(tm) -- West Palm Beach, FL
Website Design, Internet Strategy, Search Engine Marketing

www.dphin.com
 
Old May 10th, 2005, 03:53 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

IIS will always have to have a hold on the file you upload, at least at the point of upload. I'm not sure what the problem is with letting go of the lock as we have both found.

There aren't many options for uploading files apart from the way you are doing it. About the only other solution would be an FTP into the image location. But this isn't practical for web application users who aren't familiar with or don't have the tools for FTP.

-Peter
 
Old June 18th, 2005, 09:15 AM
Registered User
 
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To get around this, you need to upload files initially to the ASP.Net temp directory, and from there you can manipulate them as needed. To get the path to the temp directory, call System.IO.Path.GetTempPath()
 
Old November 8th, 2005, 11:56 AM
Authorized User
 
Join Date: Jun 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have just spent two days tackling a similar issue in ASP.

I created an ASP page that uses a database SELECT statement and html TABLE to create an Excel spreadsheet. To create the spreadsheet, I used:
 
  • Response.ContentType = "application/vnd.ms-excel"
  •   
  • Response.AddHeader "content-disposition","attachment; filename=MyFile.xls"


PROBLEM:
    First time user opens window and clicks on link, Excel spitout works GREAT!! Then the user closes their active window. Does not matter if they logout properly or not. When a new window is opened, and user logs back into the ASP app and tries to press link again, they then receive an error message:

        "Microsoft Excel cannot access the file 'http://www.myurl.com/dir1/excel_spitout.asp'. There are several possible reasons:
   
  • The file name or path name does not exist.
  •   
  • The file you're trying to open is being used by another program. Close the document in the other program, and try again.
      
  • The name of the workbook you're trying to save is the same as the name of another document that is read-only. Try saving the workbook with a different name."


WORKAROUND:
I discovered that, whenever the error occurred, I could click on ANY OTHER LINK on my ASP page - so long as it was a link that made a database request - and then press the BACK button, come back to my original page, and then press my Excel link again, and ... voila!! The link would suddenly work!

It would not, however, work if the link I pressed was an HTML only page or did not make a database request from the server / back-end database.

Clearly this indicated that the Excel object (or maybe some other object) was being retained in memory, and that opening a new db connection and executing a recordset seemed to wipe it out.

I Googled and Googled and the only good answer I found on this topic was that this was a known issue in XL97 and that Microsoft had created a patch for it.

See: http://support.microsoft.com/default...b;en-us;151064

Fat lot of good a service pack for XL97 would do me when I and most of my users are using XL2003.


CHEAP AND DIRTY RESOLUTION:
I hate that I did this, but seeing as how no one has come up with a "clean" way to resolve this, such as using code to determine if the Excel object is still open or not, and I could not figure out how to do so by myself, I opted for a cheap & dirty solution. I created a new ASP page, called whenever the user presses on the "Create Excel Spitout" link. This intermediary web page does nothing more than:
  • opens a database connection
     
  • creates a small recordset (does not matter what info is retrieved, so long as the database is engaged in activity)
      
  • executes it, then closes it, then ...
     
  • redirects user to the ACTUAL "Create Excel Spitout" link.

I offer this solution to anyone who has been driven MAD by the MS Office bug that creates this error!! This also is a challenge --> if any of you can come up with a more sophisticated solution, I would love to hear about it.

Hoping this helps someone,

Susan Henesy



Susan :)
 
Old January 17th, 2007, 10:28 AM
Registered User
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi all,

This is by no means a fix - like many of you, I have coded and searched for an ideal solution to this bug but all attempts have proved to be fruitless - but this has worked for me.

Similar to MissHenesy, if prior to or after your attempt to work on the file, you force your application to do some sort of complex query this will release the lock held on the file by ASPNET or IIS (or both), allowing you to read, write, delete, etc.

As i said, by no means a fix (and certainly not ideal), but it works!

 
Old July 28th, 2009, 02:05 AM
Registered User
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Alternative

Hi frndz,
I am facing the same problem, i have an alternative, set a bit field if you want to delete the file in DB, at certain time in a day run a batch file which can remove the images whose status will be deleted. While displaying such images before deletion check for status.

It may not be a solution but may an alternative.

Thanks.
 
Old September 16th, 2009, 05:03 AM
Registered User
 
Join Date: Sep 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi..
I read your post and as per that i think one of your process remain as it is so from that when you try to run it on other side so you can not exist that file so first you have to check that by toolbar so you can solve out your problem.... Thanks for sharing the post....
 
Old May 23rd, 2014, 04:38 AM
Registered User
 
Join Date: May 2014
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You receive a "The process cannot access the file because it is being used by another process" error message when you try to start a Web site in the Internet Information Services MMC snap-in Print Print Email Email





Similar Threads
Thread Thread Starter Forum Replies Last Post
The process cannot access the file nelly78 .NET Framework 2.0 3 July 22nd, 2008 06:59 AM
The process cannot access the file while publishin madhu15583 ASP.NET 1.0 and 1.1 Professional 0 June 19th, 2008 01:58 AM
[Resolved] Error: File used by another process snufse .NET Framework 2.0 2 February 18th, 2008 09:20 AM
file error ...being used by another process rreynolds Pro VB.NET 2002/2003 6 January 11th, 2005 11:56 AM
DTS text file export - Batch Process Tim Barbour SQL Server DTS 1 November 23rd, 2004 11:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.