Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2012 Help Handling "System.UnauthorizedAccessException" Exception

$
0
0
Guys i really need help with this one, Basically im making a file deleter thats collects all the files in a folder then places then in a checkedlistbox. Then i have a "clean" button which has the code
<CODE>ProgressBar1.Minimum = 0
ProgressBar1.Maximum = CheckedListBox1.Items.Count = -1
ProgressBar1.Value = 0

For Each itm As String In CheckedListBox1.Items


IO.File.Delete(itm)

MsgBox("File failed to delete")
Exit Sub




ProgressBar1.Increment(1)
Next

ProgressBar1.Value = 0
End Sub</CODE>


When there is a file that can not be deleted i get the System.UnauthorizedAccessException exception.
which you can see here: https://dl.dropboxusercontent.com/u/...47/Capture.PNG

If someone can help me it would be appreciated. im new to VB.

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>