Okay, I still havenot figured out a way to resolve this problem. As simple as my program is, I am trying to list the directories in a treeview and then when an user clicks on it, I am listing all the files in an listview box. I am getting "Unauthorized Access Exception" when I click on 'My Document' folder and also on some other folders. How to resolve this? I am not even opening any files, just listing files from a directory I click on treeview.
When I use FolderBrowserDialog, I don't get this exception and am able to browse to MyDocuments Folder and even open a file.
Try
Dim strdirs() As String = IO.Directory.GetDirectories(ds)
tv1_temp(arr_ind(0)).Nodes.clear()
For Each d As String In strdirs
Dim ss = d.Substring(d.LastIndexOf(IO.Path.AltDirectorySeparatorChar) + 1)
Dim tn = New TreeNode(ss)
tn.Name = ss
tv1_temp(arr_ind(0)).Nodes.Add(tn)
Next
tv1_temp(arr_ind(0)).ExpandAll()
Catch ex As IO.IOException
Comment.Text = "Device not ready!"
Catch ex As System.UnauthorizedAccessException
Comment.Text = ("Unauthorized Access to this directory!")
End Try
Thank you!