M
MichaelEvans1000
Please someone tell me what i'm doing wrong here. I trying to access
the "files" variable, however i'm getting an "object not set to a
instance". I want to be able to move to the next record if this
"UnauthorizedAccessException" error occurs.
Dim files As ReadOnlyCollection(Of String)
Dim obj As New WinControl
Dim WS As New CollectionWS.CollectionBroker
Dim ds As New System.Data.DataSet
Dim dt As New System.Data.DataTable
Dim dr As System.Data.DataRow
Dim Name As String
Dim Drive As DriveInfo
Dim Dname As String
WS.Credentials = System.Net.CredentialCache.DefaultCredentials
ds = WS.GetCollectionTypes
dt = ds.Tables(0)
'Get Local drive information
For Each Drive In System.IO.DriveInfo.GetDrives
Dname = Drive.Name
For Each dr In dt.Rows
Try
Name = dr.Item(1)
files = My.Computer.FileSystem.GetFiles(Dname,
FileIO.SearchOption.SearchTopLevelOnly, "*." & Name)
files.GetEnumerator.MoveNext()
obj.GetFileProperties(files, Name)
Catch ex As IOException
Exit For
Catch ex As UnauthorizedAccessException
'I want to move to the next record and try to access it
files.GetEnumerator.MoveNext()
End Try
Next
Next
the "files" variable, however i'm getting an "object not set to a
instance". I want to be able to move to the next record if this
"UnauthorizedAccessException" error occurs.
Dim files As ReadOnlyCollection(Of String)
Dim obj As New WinControl
Dim WS As New CollectionWS.CollectionBroker
Dim ds As New System.Data.DataSet
Dim dt As New System.Data.DataTable
Dim dr As System.Data.DataRow
Dim Name As String
Dim Drive As DriveInfo
Dim Dname As String
WS.Credentials = System.Net.CredentialCache.DefaultCredentials
ds = WS.GetCollectionTypes
dt = ds.Tables(0)
'Get Local drive information
For Each Drive In System.IO.DriveInfo.GetDrives
Dname = Drive.Name
For Each dr In dt.Rows
Try
Name = dr.Item(1)
files = My.Computer.FileSystem.GetFiles(Dname,
FileIO.SearchOption.SearchTopLevelOnly, "*." & Name)
files.GetEnumerator.MoveNext()
obj.GetFileProperties(files, Name)
Catch ex As IOException
Exit For
Catch ex As UnauthorizedAccessException
'I want to move to the next record and try to access it
files.GetEnumerator.MoveNext()
End Try
Next
Next