Unable to delete file through vb. Net

  • Thread starter Thread starter Hyperspace2
  • Start date Start date
  • Tags Tags
    Delete File Net
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 3K views
Hyperspace2
Messages
84
Reaction score
1
Even if I use correct method or code for deleting files and folders, when debugging I get error saying that it cannot access file and hence cannot delete it. What setting of computer I should inprove to enable the delete feature through visual basic 2008
 
Physics news on Phys.org
I mean the code as. System.IO.file.delete(path of file) doesn't work nor kill(path of the file) works. I think my pc setting is weird. Someone tell me how to correct it.
 
I'm going to guess that your VB program doesn't have the correct access rights to delete the file. What exception are you getting? The Delete method throws UnauthorizedAccessException if the caller doesn't have the required permission to delete the file.

It also might be that the file you want to delete has its read-only attribute set.