[RESOLVED] Permission Denied When Trying To Delete A File-VBForums
Results 1 to 33 of 33

Thread: [RESOLVED] Permission Denied When Trying To Delete A File

  1. #1

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Resolved [RESOLVED] Permission Denied When Trying To Delete A File

    I'm using the following code to copy some lines from file into a new file. After all the correct lines are copied, I delete the old file. This was working just fine last week. But suddenly it's not working on several computers and I don't know why it's not working.

    Code:
    Public Function DeleteLines(ByVal from_name As String, ByVal to_name As String, ByVal target As String) As Long
        Dim strlen As Integer
        Dim from_file As Integer
        Dim to_file As Integer
        Dim one_line As String
        Dim deleted As Integer
    
        ' Open the input file.
        from_file = FreeFile
        Open from_name For Input As from_file
    
        ' Open the output file.
        to_file = FreeFile
        Open to_name For Output As to_file
    
        ' Copy the file skipping lines containing the
        ' target.
        deleted = 0
        
        Do While Not EOF(from_file)
            Line Input #from_file, one_line
            If InStr(one_line, target) > 0 Then
                Print #to_file, one_line
            Else
                deleted = deleted + 1
            End If
        Loop
    
        ' Close the files.
        Close from_file
        Close to_file
        
        MsgBox ("before kill")
        Kill (from_name)
          MsgBox ("after kill")
        Name to_name As from_name
        
        DeleteLines = deleted
    End Function
    It fails on the Kill (from_name) line. It says that it doesn't have permission. I'l closing the file before killing, so I don't know what the issue is.

    Anyone have any ideas?
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    3,668

    Re: Permission Denied When Trying To Delete A File

    Found nothing wrong with your code...works fine for me. I am working in the app.path, to which I have read/write privileges.
    Are you using a path to which you might not have those privileges? Try app.path first. If that doesn't help, use VB's Sleep command (say 1 sec) before the kill command. (Include this line in your declarations for Sleep: Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

  3. #3

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Permission Denied When Trying To Delete A File

    Quote Originally Posted by SamOscarBrown View Post
    Found nothing wrong with your code...works fine for me. I am working in the app.path, to which I have read/write privileges.
    Are you using a path to which you might not have those privileges? Try app.path first. If that doesn't help, use VB's Sleep command (say 1 sec) before the kill command. (Include this line in your declarations for Sleep: Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
    I checked the path and it's good. I tried sleep like you recommended, I even tried it with 10 seconds, but it didn't help.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    3,668

    Re: Permission Denied When Trying To Delete A File

    I set the properties on my from_file to 'read only', and of course, I got an error when trying to kill it. However, not the same error as you.
    You say it works on SOME computers, but not others....are they all running the same OS? What is that OS, if only one?
    Is your file set to 'read only'? Do each of the signed-in users have permission to write to the directory in which the file is located?

  5. #5

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Permission Denied When Trying To Delete A File

    Quote Originally Posted by SamOscarBrown View Post
    I set the properties on my from_file to 'read only', and of course, I got an error when trying to kill it. However, not the same error as you.
    You say it works on SOME computers, but not others....are they all running the same OS? What is that OS, if only one?
    Is your file set to 'read only'? Do each of the signed-in users have permission to write to the directory in which the file is located?
    The file isn't readonly and it doesn't work on any machine. But they're all Windows 7 and each PC has UAC turned off and are admins.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  6. #6
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    3,668

    Re: Permission Denied When Trying To Delete A File

    If the file is open (i.e., the close function didn't have time to work) you would get '''

    Sorry...double post...what is the error you get?
    Now, you know, once you run it ONE time, your original 'from_file' is deleted (hopefully), then of course, it would not work a second time....but regardless, what is the specific error on the Kill)(rom_name) line? Oops. disrecard last...I had commented out your copy command.....
    Last edited by SamOscarBrown; Dec 4th, 2012 at 01:53 PM.

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    8,147

    Re: Permission Denied When Trying To Delete A File

    I ran into some issues like this on one of my pcs a few days ago. It was a security issue on the drive and I had to reset the permissions. Basically I could create a new file and write to it but could not modify and existing file nor could I delete and exitsting file. I right clicked ont he drive and set the permissions and the problem was gone.

  8. #8
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    3,668

    Re: Permission Denied When Trying To Delete A File

    Hmmm, on the DRIVE???? That's interesting.

    Above, my double post did not double post afterall....what I was saying you would get different errors if the file was readonly, if the file was still open, and whatever you got for your errror (permissions????). It WOULD help to know the specific error. Maybe DM's Drive Permission thing may be what you need to do....never ran into that before.

  9. #9

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Permission Denied When Trying To Delete A File

    Quote Originally Posted by SamOscarBrown View Post
    Hmmm, on the DRIVE???? That's interesting.

    Above, my double post did not double post afterall....what I was saying you would get different errors if the file was readonly, if the file was still open, and whatever you got for your errror (permissions????). It WOULD help to know the specific error. Maybe DM's Drive Permission thing may be what you need to do....never ran into that before.
    It just says RunTime Error 70. Permission denied.

    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  10. #10
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    3,668

    Re: Permission Denied When Trying To Delete A File

    Okay, here 9is what MS says causes that---check EACH:

    Visual Basic for Applications Reference

    Visual Studio 6.0

    2 out of 29 rated this helpful - Rate this topic



    Permission denied (Error 70)

    See Also Specifics
    An attempt was made to write to a write-protected disk or to access a locked file. This error has the following causes and solutions:
    • You tried to open a write-protected file for sequential Output or Append. Open the file for Input or change the write-protection attribute of the file.
    • You tried to open a file on a disk that is write-protected for sequential Output or Append. Remove the write-protection device from the disk or open the file for Input.
    • You tried to write to a file that another process locked. Wait to open the file until the other process releases it.
    • You attempted to access the registry, but your user permissions don't include this type of registry access. On 32-bit Microsoft Windows systems, a user must have the correct permissions for access to the system registry. Change your permissions or have them changed by the system administrator.

  11. #11

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Permission Denied When Trying To Delete A File

    Quote Originally Posted by SamOscarBrown View Post
    Okay, here 9is what MS says causes that---check EACH:

    Visual Basic for Applications Reference

    Visual Studio 6.0

    2 out of 29 rated this helpful - Rate this topic



    Permission denied (Error 70)

    See Also Specifics
    An attempt was made to write to a write-protected disk or to access a locked file. This error has the following causes and solutions:
    • You tried to open a write-protected file for sequential Output or Append. Open the file for Input or change the write-protection attribute of the file.
    • You tried to open a file on a disk that is write-protected for sequential Output or Append. Remove the write-protection device from the disk or open the file for Input.
    • You tried to write to a file that another process locked. Wait to open the file until the other process releases it.
    • You attempted to access the registry, but your user permissions don't include this type of registry access. On 32-bit Microsoft Windows systems, a user must have the correct permissions for access to the system registry. Change your permissions or have them changed by the system administrator.
    It's a generic file permissions error. I've Googled this error for quite some and came across that document as well. Nothing there applies to this situation.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  12. #12
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    3,668

    Re: Permission Denied When Trying To Delete A File

    yeah...I thought it might have been that the file was not yet closed, hence the sleep...but, I am now out of ideas.....Sorry I could not help you...it works just fine on my Win7 32Bit machine.

  13. #13
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    8,147

    Re: Permission Denied When Trying To Delete A File

    Have you tried setting the permissons under the security tab on the drive where the files are located? If you files are on a local drive and are not set to read only then this is the most likely source of the problem. If it is a shared network drive then you would want to also check the sharing permissions.

  14. #14
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,626

    Re: Permission Denied When Trying To Delete A File

    where is your file located? might be a protected folder... permissions could give you access

    have you tried moving the file then deleting it? try moving it to your desktop (via Code of course)... if it does not move or delete it is being used by a program

  15. #15
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Permission Denied When Trying To Delete A File

    Can you manually delete the file ? (i.e. right click on it and select 'Delete') If not, then it's a Permissions issue as previously suggested. If you can, then it's a sharing problem (e.g. something else has the file open) You could try
    Code:
    Open from_name For Input Access Read Lock Read Write As from_file
    to see if you can get exclusive control. If something has the file open already then the above Open should fail.

    If you're on a Domain then there might be a policy overriding the permissions and you'll need a Domain Admin to make a change.

    Also, even though you have Administrator rights you may have to run your app with eleveated privileges (i.e. right click you application and select 'Run as Administrator')

    EDIT: Your first Post suggestes that it used to work. That being the case, something must have changed. Probably something to do with the environment.
    Last edited by Doogle; Dec 5th, 2012 at 01:21 AM.

  16. #16
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    4,987

    Re: Permission Denied When Trying To Delete A File

    Quote Originally Posted by Doogle View Post
    Also, even though you have Administrator rights you may have to run your app with eleveated privileges (i.e. right click you application and select 'Run as Administrator')
    He has UAC off which means by default, all apps run in the highest privilege available.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  17. #17
    Lively Member
    Join Date
    Sep 2008
    Posts
    127

    Re: Permission Denied When Trying To Delete A File

    My suggestion is to turn off antivirus and check if it works. If it works add an exception.

  18. #18
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,364

    Re: Permission Denied When Trying To Delete A File

    Try this:

    After both files are closed and before trying to Kill the old file insert a Reset statement. See if this corrects the problem. If so, I suspect you're running afoul of the way the VB6 Close statement works - it is not a simple synchronous close.

    You might also be running into file system tunnelling but I don't think that's at work here.

  19. #19

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Permission Denied When Trying To Delete A File

    Quote Originally Posted by DataMiser View Post
    Have you tried setting the permissons under the security tab on the drive where the files are located? If you files are on a local drive and are not set to read only then this is the most likely source of the problem. If it is a shared network drive then you would want to also check the sharing permissions.
    Security permissions are not an issue. I have full control over everything. This same error occurs on two different machines. Both are running Windows 7 Pro with UAC turned off.

    Quote Originally Posted by Max187Boucher View Post
    where is your file located? might be a protected folder... permissions could give you access

    have you tried moving the file then deleting it? try moving it to your desktop (via Code of course)... if it does not move or delete it is being used by a program
    I can delete it just fine outside of the program. I even ran Unlocker on it just in case. No go.

    Quote Originally Posted by Doogle View Post
    Can you manually delete the file ? (i.e. right click on it and select 'Delete') If not, then it's a Permissions issue as previously suggested. If you can, then it's a sharing problem (e.g. something else has the file open) You could try
    Code:
    Open from_name For Input Access Read Lock Read Write As from_file
    to see if you can get exclusive control. If something has the file open already then the above Open should fail.

    If you're on a Domain then there might be a policy overriding the permissions and you'll need a Domain Admin to make a change.

    Also, even though you have Administrator rights you may have to run your app with eleveated privileges (i.e. right click you application and select 'Run as Administrator')

    EDIT: Your first Post suggestes that it used to work. That being the case, something must have changed. Probably something to do with the environment.
    I can delete the file just fine outside of the application. Also, UAC is turned off. So running as admin won't affect it.

    Quote Originally Posted by brandoncampbell View Post
    My suggestion is to turn off antivirus and check if it works. If it works add an exception.
    AV is not affecting this. My dev machine is running MSSE. The other machine is running nothing.

    Quote Originally Posted by dilettante View Post
    Try this:

    After both files are closed and before trying to Kill the old file insert a Reset statement. See if this corrects the problem. If so, I suspect you're running afoul of the way the VB6 Close statement works - it is not a simple synchronous close.

    You might also be running into file system tunnelling but I don't think that's at work here.
    Wait. File system closing isn't a synchronous action in VB6? But, I did a Sleep earlier and it still didn't work. I did it for 10 seconds. But I'll test it longer and see what happens. I'll also check that article.

    Thanks
    Last edited by weirddemon; Dec 5th, 2012 at 04:27 PM.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  20. #20
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,364

    Re: Permission Denied When Trying To Delete A File

    It might require that you exit the current event handler before Close takes effect. Reset forces all files closed, and a DoEvents() call might trigger pending Closes to complete as well for all I know but I'd avoid that.

  21. #21
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    8,147

    Re: Permission Denied When Trying To Delete A File

    Security permissions are not an issue. I have full control over everything. This same error occurs on two different machines. Both are running Windows 7 Pro with UAC turned off.
    Ddid you check what I told you?

    It has nothing to do with UAC. What I am referring to is in the NTFS security and is found under the security tab on the drive. Liek I said I ran into this int he last couple of weeks on Windows 7 Pro and the problem was the security settings on the drive which had somehow blocked me from modifing/deleting files on that drive after a new install.

  22. #22

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Permission Denied When Trying To Delete A File

    Quote Originally Posted by dilettante View Post
    It might require that you exit the current event handler before Close takes effect. Reset forces all files closed, and a DoEvents() call might trigger pending Closes to complete as well for all I know but I'd avoid that.
    I tried Reset, but it did't work.

    Quote Originally Posted by DataMiser View Post
    Ddid you check what I told you?

    It has nothing to do with UAC. What I am referring to is in the NTFS security and is found under the security tab on the drive. Liek I said I ran into this int he last couple of weeks on Windows 7 Pro and the problem was the security settings on the drive which had somehow blocked me from modifing/deleting files on that drive after a new install.
    If your read my reply above, you'd see that I told you that the security permission are fine. I double checked it and my account has access to everything. On both machines.

    I'm going to try out some other things today and see what I get.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  23. #23

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Permission Denied When Trying To Delete A File

    Ok. I've done a couple of things. I tried making the method the very first action in Form_Load to rule out any other code screwing it up. That didn't work. Then I tried deleting the file in the first line of the method. That also didn't work. So then I tried deleting the file in the first line of Form_Load. That worked. No idea what that worked though. It's not a solution, but for some reason I can delete the file outside of the method, but not inside. I'm still playing around with it.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  24. #24
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,364

    Re: Permission Denied When Trying To Delete A File

    It might help a lot to know where you are doing this. Many special folders are set up with "owner access" meaning that any user can create a file there and he has full ownership, but other users only have read access to that file. This is entirely separate from UAC issues.

    Of course running as an admin user bypasses that.

    Just additional info though, since you say killing the file outside your method is somehow magically making a difference. I can't reproduce the problem here.

  25. #25

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Permission Denied When Trying To Delete A File

    Quote Originally Posted by dilettante View Post
    It might help a lot to know where you are doing this. Many special folders are set up with "owner access" meaning that any user can create a file there and he has full ownership, but other users only have read access to that file. This is entirely separate from UAC issues.

    Of course running as an admin user bypasses that.

    Just additional info though, since you say killing the file outside your method is somehow magically making a difference. I can't reproduce the problem here.
    I think that at this point, it becomes irrelevant where the file is located since it *can* be deleted from the application. However, it's just a folder from the user documents on my PC and the program files on the other PC.

    Also, I think it's important to note that the method is being called from another method. So it goes something like this Form_Load --> MainMethod --> DeletionMethod. I'm going to try and call the deletion method directly to see if the MainMethod is causing an issue somewhere.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  26. #26

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Permission Denied When Trying To Delete A File

    Ugh... yeah. It worked if I called the deletion method by itself. Which means that the MainMethod must be locking up the file somewhere. More digging to do.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  27. #27
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    734

    Re: Permission Denied When Trying To Delete A File

    I agree - post the actual path you are using for the file. That would be helpful.

  28. #28

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Permission Denied When Trying To Delete A File

    Quote Originally Posted by jdc2000 View Post
    I agree - post the actual path you are using for the file. That would be helpful.
    I'm not sure why you guys won't listen. It has nothing to do with the permissions of the path.

    Also, I just resolved the issue. The MainMethod opens up the XML file to retrieve the data. If a condition is met, it sends a part of that data to the DeletionMethod. The DeletionMethod uses that data to delete lines from the file. The problem, was that I was opening the file in the MainMathod, passing the data to the deletion method, but not closing the file from the MainMethod until after the DeletionMethod was called. It works now.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  29. #29
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,626

    Re: Permission Denied When Trying To Delete A File

    Quote Originally Posted by Max187Boucher View Post
    where is your file located? might be a protected folder... permissions could give you access

    have you tried moving the file then deleting it? try moving it to your desktop (via Code of course)... if it does not move or delete it is being used by a program
    I asked you a simple thing to do... I knew it was still opened somehow

  30. #30
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    3,668

    Re: [RESOLVED] Permission Denied When Trying To Delete A File

    ....glad you found it.....but we DID try to help....all had great suggestions, and as we pointed out a few times, it was probably because the file was somehow still open......

    from above:

    Permission denied (Error 70)

    See Also Specifics
    An attempt was made to write to a write-protected disk or to access a locked file. This error has the following causes and solutions:
    • You tried to open a write-protected file for sequential Output or Append. Open the file for Input or change the write-protection attribute of the file.
    • You tried to open a file on a disk that is write-protected for sequential Output or Append. Remove the write-protection device from the disk or open the file for Input.
    • You tried to write to a file that another process locked. Wait to open the file until the other process releases it.
    • You attempted to access the registry, but your user permissions don't include this type of registry access. On 32-bit Microsoft Windows systems, a user must have the correct permissions for access to the system registry. Change your permissions or have them changed by the system administrator.
    It's a generic file permissions error. I've Googled this error for quite some and came across that document as well. Nothing there applies to this situation.

    --------seems like ONE of those DID apply to your sit.... :-)

    Anyway, glad you tracked it down...good work!

  31. #31

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: Permission Denied When Trying To Delete A File

    Quote Originally Posted by Max187Boucher View Post
    I asked you a simple thing to do... I knew it was still opened somehow
    You kept going on about permission issues. Which I said many times had nothing to do with this.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  32. #32

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,827

    Re: [RESOLVED] Permission Denied When Trying To Delete A File

    Quote Originally Posted by SamOscarBrown View Post
    ....glad you found it.....but we DID try to help....all had great suggestions, and as we pointed out a few times, it was probably because the file was somehow still open......

    from above:

    Permission denied (Error 70)

    See Also Specifics
    An attempt was made to write to a write-protected disk or to access a locked file. This error has the following causes and solutions:
    • You tried to open a write-protected file for sequential Output or Append. Open the file for Input or change the write-protection attribute of the file.
    • You tried to open a file on a disk that is write-protected for sequential Output or Append. Remove the write-protection device from the disk or open the file for Input.
    • You tried to write to a file that another process locked. Wait to open the file until the other process releases it.
    • You attempted to access the registry, but your user permissions don't include this type of registry access. On 32-bit Microsoft Windows systems, a user must have the correct permissions for access to the system registry. Change your permissions or have them changed by the system administrator.
    It's a generic file permissions error. I've Googled this error for quite some and came across that document as well. Nothing there applies to this situation.

    --------seems like ONE of those DID apply to your sit.... :-)

    Anyway, glad you tracked it down...good work!
    I didn't say people did try to help. I'm saying people focused on things I said *wasn't* the problem. Mainly referring to security and UAC that I ruled out many, many, many times. I just think if you're going to try to assist someone, you should read what they've done to resolve the issue already. Suggesting the same thing over and over is not helpful.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  33. #33
    PowerPoster
    Join Date
    Feb 2006
    Posts
    11,364

    Re: [RESOLVED] Permission Denied When Trying To Delete A File

    One thing that is really helpful is to create a small test case isolating the problem logic.

    Often by creating and testing such a small program you'll find the answer yourself. But then even if you don't find it, providing a small complete program that reliably reproduces the problem can go a long way to getting to a cause and a solution more quickly.

    If you can't reproduce the problem that usually tells you a lot in itself, as in this case where something else in the program we were never told about caused the symptoms.


    Just something to keep in mind. It might have helped avoid some of the "noise" the rest of us injected into this thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.