File Access Denied!

  • Thread starter Thread starter tarkan
  • Start date Start date
T

tarkan

Hi ,
Platform VB.Net
I have a form with a listview(filled with all the ".bmp" files on "c:\") and
a picture box.
The picturebox displays the image files which are in selected mode on the
listview .
My problem is, i get the "security_exception" error,when i try to delete the
selected files in the listview.
I use the "filesystemobject" to delete the file(s).
I try to dispose the images displayed by the picturebox but still the same
error is thrown.
I'm sure that all of the image files are in "normal mode", not "readonly".

Any suggestions!
Thanks.
Tarkan
 
Hi tarkan,
To delete files, use the following:

IO.File.Delete(fname)

Where fname is the full path of the file to delete, for instance
"c:\test\file.bmp".
If you still get Access Denied, then it's because of system level security
permissions!
Try to delete the same file with Windows Explorer. If you cant with Windows
Explorer, that's because you are not logged as administrator or have no
rights to do it.
That is obvious! If an user runs your application on a Windows XP limited
account the application privileges are the same as user's. That means he
will not be able to delete some folders and files. That is normal and "by
design". What your application should do is to catch the exceptions and
handle it in an user-friendly way (message box, button disable, or
whatever).

Regards,
Mario
 
Back
Top