There are 25 machines on domain and I need to read a file that is protected, I can change manually in each machine which user can read/write but that seems not an option, so I want to know if before the "system.unauthorizedAccessException" appears I can give some credentials like if I were an Authorized user.
This code works only in one machine just because I change manually the folder's security properties so EVERYONE can read/write, but I can't do that in the rest.
Do
If day_dif >= 0 Then
sum_iteraciones = sum_iteraciones + iteraciones(patho)
num = num + 1
patho = "\\" & Eqp & "\Log_SG2X\" & Strings.Right("000" & Year(today), 4) & "\" & Strings.Right("00" & Month(today), 2) & "\" & Strings.Right("00" & Microsoft.VisualBasic.DateAndTime.Day(today), 2) & "\Sequence\" & Mesa & "\" & Strings.Right("000" & Year(today), 4) & Strings.Right("00" & Month(today), 2) & Strings.Right("00" & Microsoft.VisualBasic.DateAndTime.Day(today), 2) & Strings.Right("00" & num, 2) & ".log"
If Not File.Exists(patho) Then
num = 0
today = today.AddDays(1)
day_dif = day_dif - 1
End If
End If
Loop Until today >= day_fin
Label1.Text = sum_iteraciones
End Sub
Private Function iteraciones(path As String)
Dim texto As String = File.ReadAllText(path)
Dim count As Integer = Split(texto, "Probe down.").Length - 1
Return count
End Function