locked
ASP.NET File deletion.... RRS feed

  • Question

  • User-601710408 posted
    I used an example frot the MSDN to delete a file. Im not sure what user to grant access as the users to let .NET operate already have full permissions.
    Any help would be greatley appreciated. Also I have tried another way to delete the file, but I am getting a similar result of "file in use by another process"...

    Server Error in '/sites/itsr' Application.

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ApplicationException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    Source Error:

    Line 207:        'myFile.Delete(HttpContext.Current.Server.MapPath("Data\userImages\" & ID & xChkNodes.Attributes(2).InnerText))
    Line 208:        Dim ISOStore As System.IO.IsolatedStorage.IsolatedStorageFile
    Line 209:        ISOStore = System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IO.IsolatedStorage.IsolatedStorageScope.User Or IO.IsolatedStorage.IsolatedStorageScope.Assembly, Nothing, Nothing)
    Line 210:        ISOStore.DeleteFile(HttpContext.Current.Server.MapPath("Data\userImages\" & ID & xChkNodes.Attributes(2).InnerText))
    Line 211:        xElems.RemoveChild(xChkNodes)

    Source File: d:\inetpub\wwwroot\sites\itsr\App_Code\sfunctions.vb    Line: 209

    Thursday, January 10, 2008 11:19 AM

Answers

  • User-601710408 posted

    I was using the file.delete method.... It was giving me a file in use by another process error. I did fix this however, I was using a memory image that held the file open for some reason. The problem cleared up after invoking the dispose method of the image.

    Thanks,

    Jeff

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 10, 2008 6:44 PM

All replies

  • User-281134609 posted

    Have you checked  that you can manually delete the file?  Maybe the file is actually being used.  Maybe you are opened the file with your code and never closed it?

    You should probably provide more information as to what is going on around this error. 

    Thursday, January 10, 2008 3:06 PM
  • User1672132137 posted

    First Try to use System.IO.File.Delete method instead. Second make sure that ASPNET account has read/write permission on the folder containing that file to be able to delete it

    HC 

    Thursday, January 10, 2008 3:12 PM
  • User-601710408 posted

    I was using the file.delete method.... It was giving me a file in use by another process error. I did fix this however, I was using a memory image that held the file open for some reason. The problem cleared up after invoking the dispose method of the image.

    Thanks,

    Jeff

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, January 10, 2008 6:44 PM