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

VS 2013 Directory name not valid and access refused

$
0
0
i'm trying to get a given path folders and files but i get the error in the title either "Directory name not valid" or " access refused" and i'm using folderbrowserdialog to select a path
this is the code used
Code:

Private Sub showfiles(ByVal path As String)
        Try
            Dim panel As GridPanel = mygrid.PrimaryGrid
            panel.Rows.Clear()
            mygrid.BeginUpdate()
            Dim folders() As String = IO.Directory.GetDirectories(path)
            Dim files() As String = IO.Directory.GetFiles(path)
            For i As Integer = 0 To folders.Length - 1
                Try
                    If My.Computer.FileSystem.GetDirectoryInfo(folders(i)).Attributes <> IO.FileAttributes.Normal Then
                        My.Computer.FileSystem.GetDirectoryInfo(folders(i)).Attributes = IO.FileAttributes.Normal
                        panel.Rows.Add(New GridRow(Format(Now, "HH:mm:ss"), folders(i), "Unhidden"))
                    Else
                        panel.Rows.Add(New GridRow(Format(Now, "HH:mm:ss"), folders(i), "Normal"))
                    End If
                    showfiles(folders(i))
                Catch ex As Exception
                    MsgBox(ex.Message, MsgBoxStyle.Information, "")
                    Exit Sub
                End Try
            Next
            For i As Integer = 0 To files.Length - 1
                Try
                    If My.Computer.FileSystem.GetFileInfo(files(i)).Attributes <> IO.FileAttributes.Normal Then
                        My.Computer.FileSystem.GetFileInfo(files(i)).Attributes = IO.FileAttributes.Normal
                        panel.Rows.Add(New GridRow(Format(Now, "HH:mm:ss"), files(i), "Unhidden"))
                    Else
                        panel.Rows.Add(New GridRow(Format(Now, "HH:mm:ss"), files(i), "Normal"))
                    End If
                    showfiles(files(i))
                Catch ex As Exception
                    MsgBox(ex.Message, MsgBoxStyle.Information, "")
                    Exit Sub
                End Try
            Next
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "")
            Exit Sub
        End Try
        mygrid.EndUpdate()
    End Sub

thank you

Viewing all articles
Browse latest Browse all 27349

Trending Articles



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