VB.NET AJUDA COM ERRO
Pessoal estou com esse erro abaixo e não sei o porque na minha máquina roda 100 %, alguém poderia analisar por favor.
Eu estou achando que é na classe clsProcuraArquivos
ERRO:
==========================================================================================================================
LOG ERRO
==========================================================================================================================
FUNÇÃO:FNCPRINCIPAL
ERRO: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator'1.CommonInit()
at System.IO.FileSystemEnumerableIterator'1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler'1 resultHandler)
at System.IO.DirectoryInfo.InternalGetFiles(String searchPattern, SearchOption searchOption)
at System.IO.DirectoryInfo.GetFiles(String searchPattern)
at AUDINV.clsProcuraArquivos.DoSearch(DirectoryInfo BaseDirectory)
at AUDINV.clsProcuraArquivos.Search(DirectoryInfo InitalDirectory, String FileMask, String DirectoryMask)
at AUDINV.clsProcuraArquivos.Search(String InitalDirectory, String FileMask, String DirectoryMask)
at AUDINV.frmPrincipal.fncPrincipal() O dispositivo não está pronto.
ESTAÇÃO:SERVIDOR1
USUÃRIO:ADMINISTRADOR
==========================================================================================================================
CLASSE:
Option Strict On
Option Explicit On
Imports System.IO
Imports System.Collections.Specialized
Public Class clsProcuraArquivos
Private Const DefaultFileMask As String = [Ô]*.*[Ô]
Private Const DefaultDirectoryMask As String = [Ô]*[Ô]
#Region [Ô] Member Variables [Ô]
Private _InitialDirectory As DirectoryInfo
Private _DirectoryMasks As StringCollection
Private _FileMasks As StringCollection
[ô]
Private _Directories As New ArrayList
Private _Files As New ArrayList
#End Region
#Region [Ô] Properites [Ô]
Public Property InitialDirectory() As DirectoryInfo
Get
Return _InitialDirectory
End Get
Set(ByVal Value As DirectoryInfo)
_InitialDirectory = Value
End Set
End Property
Public Property DirectoryMask() As StringCollection
Get
Return _DirectoryMasks
End Get
Set(ByVal Value As StringCollection)
_DirectoryMasks = Value
End Set
End Property
Public Property FileMask() As StringCollection
Get
Return _FileMasks
End Get
Set(ByVal Value As StringCollection)
_FileMasks = Value
End Set
End Property
Public ReadOnly Property Directories() As ArrayList
Get
Return _Directories
End Get
End Property
Public ReadOnly Property Files() As ArrayList
Get
Return _Files
End Get
End Property
#End Region
#Region [Ô] Constructors [Ô]
Public Sub New()
End Sub
Public Sub New( _
ByVal BaseDirectory As String)
Me.New(New DirectoryInfo(BaseDirectory))
End Sub
Public Sub New( _
ByVal InitialDirectory As DirectoryInfo)
_InitialDirectory = InitialDirectory
End Sub
#End Region
Public Overloads Sub Search(ByVal InitalDirectory As String, _
Optional ByVal FileMask As String = Nothing, _
Optional ByVal DirectoryMask As String = Nothing)
Search( _
New DirectoryInfo(InitalDirectory), _
FileMask, _
DirectoryMask _
)
End Sub
Public Overloads Sub Search( _
Optional ByVal InitalDirectory As DirectoryInfo = Nothing, _
Optional ByVal FileMask As String = Nothing, _
Optional ByVal DirectoryMask As String = Nothing)
_Files = New ArrayList
_Directories = New ArrayList
If Not IsNothing(InitalDirectory) Then
_InitialDirectory = InitalDirectory
End If
If IsNothing(_InitialDirectory) Then
Throw New ArgumentException([Ô]A Directory Must be specified![Ô], [Ô]Directory[Ô])
End If
If IsNothing(FileMask) OrElse FileMask.Length = 0 Then
_FileMasks = New StringCollection
_FileMasks.Add(DefaultFileMask)
Else
_FileMasks = ParseMask(FileMask)
End If
If IsNothing(DirectoryMask) OrElse DirectoryMask.Length > 0 Then
_DirectoryMasks = New StringCollection
_DirectoryMasks.Add(DefaultDirectoryMask)
Else
_DirectoryMasks = ParseMask(DirectoryMask)
End If
DoSearch(_InitialDirectory)
End Sub
Private Sub DoSearch(ByVal BaseDirectory As DirectoryInfo)
Try
For Each fm As String In _FileMasks
Files.AddRange(BaseDirectory.GetFiles(fm))
Next
_
Catch u As UnauthorizedAccessException
[ô]Siliently Ignore this error, there isnt any simple
[ô]way to avoid this error.
End Try
Try
Dim Directories As New ArrayList
For Each dm As String In _DirectoryMasks
Directories.AddRange(BaseDirectory.GetDirectories(dm))
_Directories.AddRange(Directories)
Next
For Each di As DirectoryInfo In Directories
DoSearch(di)
Next
Catch u As UnauthorizedAccessException
[ô]Siliently Ignore this error, there isnt any simple
[ô]way to avoid this error.
End Try
End Sub
[ô]Masks are formated like *.jpeg;*.jpg
Private Shared Function ParseMask(ByVal Mask As String) As StringCollection
If IsNothing(Mask) Then
Return Nothing
End If
Mask = Mask.Trim([Ô];[Ô]c)
If Mask.Length = 0 Then
Return Nothing
End If
Dim Masks As New StringCollection
Masks.AddRange(Mask.Split([Ô];[Ô]c))
Return Masks
End Function
Protected Overrides Sub Finalize()
_Files = Nothing
_Directories = Nothing
MyBase.Finalize()
End Sub
End Class
Eu estou achando que é na classe clsProcuraArquivos
ERRO:
==========================================================================================================================
LOG ERRO
==========================================================================================================================
FUNÇÃO:FNCPRINCIPAL
ERRO: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator'1.CommonInit()
at System.IO.FileSystemEnumerableIterator'1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler'1 resultHandler)
at System.IO.DirectoryInfo.InternalGetFiles(String searchPattern, SearchOption searchOption)
at System.IO.DirectoryInfo.GetFiles(String searchPattern)
at AUDINV.clsProcuraArquivos.DoSearch(DirectoryInfo BaseDirectory)
at AUDINV.clsProcuraArquivos.Search(DirectoryInfo InitalDirectory, String FileMask, String DirectoryMask)
at AUDINV.clsProcuraArquivos.Search(String InitalDirectory, String FileMask, String DirectoryMask)
at AUDINV.frmPrincipal.fncPrincipal() O dispositivo não está pronto.
ESTAÇÃO:SERVIDOR1
USUÃRIO:ADMINISTRADOR
==========================================================================================================================
CLASSE:
Option Strict On
Option Explicit On
Imports System.IO
Imports System.Collections.Specialized
Public Class clsProcuraArquivos
Private Const DefaultFileMask As String = [Ô]*.*[Ô]
Private Const DefaultDirectoryMask As String = [Ô]*[Ô]
#Region [Ô] Member Variables [Ô]
Private _InitialDirectory As DirectoryInfo
Private _DirectoryMasks As StringCollection
Private _FileMasks As StringCollection
[ô]
Private _Directories As New ArrayList
Private _Files As New ArrayList
#End Region
#Region [Ô] Properites [Ô]
Public Property InitialDirectory() As DirectoryInfo
Get
Return _InitialDirectory
End Get
Set(ByVal Value As DirectoryInfo)
_InitialDirectory = Value
End Set
End Property
Public Property DirectoryMask() As StringCollection
Get
Return _DirectoryMasks
End Get
Set(ByVal Value As StringCollection)
_DirectoryMasks = Value
End Set
End Property
Public Property FileMask() As StringCollection
Get
Return _FileMasks
End Get
Set(ByVal Value As StringCollection)
_FileMasks = Value
End Set
End Property
Public ReadOnly Property Directories() As ArrayList
Get
Return _Directories
End Get
End Property
Public ReadOnly Property Files() As ArrayList
Get
Return _Files
End Get
End Property
#End Region
#Region [Ô] Constructors [Ô]
Public Sub New()
End Sub
Public Sub New( _
ByVal BaseDirectory As String)
Me.New(New DirectoryInfo(BaseDirectory))
End Sub
Public Sub New( _
ByVal InitialDirectory As DirectoryInfo)
_InitialDirectory = InitialDirectory
End Sub
#End Region
Public Overloads Sub Search(ByVal InitalDirectory As String, _
Optional ByVal FileMask As String = Nothing, _
Optional ByVal DirectoryMask As String = Nothing)
Search( _
New DirectoryInfo(InitalDirectory), _
FileMask, _
DirectoryMask _
)
End Sub
Public Overloads Sub Search( _
Optional ByVal InitalDirectory As DirectoryInfo = Nothing, _
Optional ByVal FileMask As String = Nothing, _
Optional ByVal DirectoryMask As String = Nothing)
_Files = New ArrayList
_Directories = New ArrayList
If Not IsNothing(InitalDirectory) Then
_InitialDirectory = InitalDirectory
End If
If IsNothing(_InitialDirectory) Then
Throw New ArgumentException([Ô]A Directory Must be specified![Ô], [Ô]Directory[Ô])
End If
If IsNothing(FileMask) OrElse FileMask.Length = 0 Then
_FileMasks = New StringCollection
_FileMasks.Add(DefaultFileMask)
Else
_FileMasks = ParseMask(FileMask)
End If
If IsNothing(DirectoryMask) OrElse DirectoryMask.Length > 0 Then
_DirectoryMasks = New StringCollection
_DirectoryMasks.Add(DefaultDirectoryMask)
Else
_DirectoryMasks = ParseMask(DirectoryMask)
End If
DoSearch(_InitialDirectory)
End Sub
Private Sub DoSearch(ByVal BaseDirectory As DirectoryInfo)
Try
For Each fm As String In _FileMasks
Files.AddRange(BaseDirectory.GetFiles(fm))
Next
_
Catch u As UnauthorizedAccessException
[ô]Siliently Ignore this error, there isnt any simple
[ô]way to avoid this error.
End Try
Try
Dim Directories As New ArrayList
For Each dm As String In _DirectoryMasks
Directories.AddRange(BaseDirectory.GetDirectories(dm))
_Directories.AddRange(Directories)
Next
For Each di As DirectoryInfo In Directories
DoSearch(di)
Next
Catch u As UnauthorizedAccessException
[ô]Siliently Ignore this error, there isnt any simple
[ô]way to avoid this error.
End Try
End Sub
[ô]Masks are formated like *.jpeg;*.jpg
Private Shared Function ParseMask(ByVal Mask As String) As StringCollection
If IsNothing(Mask) Then
Return Nothing
End If
Mask = Mask.Trim([Ô];[Ô]c)
If Mask.Length = 0 Then
Return Nothing
End If
Dim Masks As New StringCollection
Masks.AddRange(Mask.Split([Ô];[Ô]c))
Return Masks
End Function
Protected Overrides Sub Finalize()
_Files = Nothing
_Directories = Nothing
MyBase.Finalize()
End Sub
End Class
Pode parecer besta, mas existe algum arquivo na pasta?
Sim, existe !
Já resolvi apesar da rotina estar bem tratada o problema estava em outra função um pouco antes, mas está resolvido agora !
Obrigado pela ajuda !!!
Já resolvi apesar da rotina estar bem tratada o problema estava em outra função um pouco antes, mas está resolvido agora !
Obrigado pela ajuda !!!
Tópico encerrado , respostas não são mais permitidas