Elenco Directory (ultimo funzionante





Vedi programma CERCA di COmponiNet

Private Sub CreaNuovoLogToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreaNuovoLogToolStripMenuItem.Click
If CheckBox2.Checked = True Then
stringa = "Desktop"
ElseIf CheckBox4.Checked = True Then
stringa = "Portatile"
ElseIf CheckBox5.Checked = True Then
stringa = "HarDisk"
End If

I = MsgBox("Confermi Ricerca directory " & stringa & " sul drive " & Mid(Drive1.Drive, 1, 1) & ":\", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "Conferma " & stringa)

If I = vbNo Then
Exit Sub
End If
IniziaTime()

Dim NomeFile As String
If CheckBox2.Checked = True Then
NomeFile = MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_Desktop.txt"
ElseIf CheckBox4.Checked = True Then
NomeFile = MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_Portatile.txt"
ElseIf CheckBox5.Checked = True Then
If CheckBox4.Checked = True Then
NomeFile = MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_Portatile_HarDisk.txt"
Else
NomeFile = MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_Desktop_HarDisk.txt"
End If
End If




' crea il file ScriviDirectory_" & Mid(Drive1.Drive, 1, 1) & "_.Bat" con comandi DOS

FileClose(1)
FileOpen(1, MyDirPath & "\INI\ScriviDirectory_" & Mid(Drive1.Drive, 1, 1) & "_.Bat", OpenMode.Output)
PrintLine(1, Mid(Drive1.Drive, 1, 1) & ":")
PrintLine(1, "@Echo on")
PrintLine(1, "cd\")
PrintLine(1, "@Echo")
PrintLine(1, "@Echo " & Chr(34) & " *****************************************************************" & Chr(34))
PrintLine(1, "@Echo attendere prego LA FINE DELLA ELABORAZIONE ....")
PrintLine(1, "@Echo " & Chr(34) & " *****************************************************************" & Chr(34))
PrintLine(1, "@Echo")
PrintLine(1, "dir /a:D /S >" & NomeFile) 'MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_.txt")
FileClose(1)
If Dir(NomeFile) <> "" Then 'MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_.txt") <> "" Then
Kill(NomeFile) '(MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_.txt")
End If
' Panel1.Visible = True

' List1.Items.Clear()





Shell(MyDirPath & "\INI\ScriviDirectory_" & Mid(Drive1.Drive, 1, 1) & "_.Bat", AppWinStyle.MaximizedFocus)
On Error GoTo Ritorna
Do
Ritorna:
Err.Clear()
If Dir(NomeFile) <> "" Then 'MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_.txt") <> "" Then
If FileLen(NomeFile) > 0 Then 'MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_.txt") > 0 Then
Dim C As Long = 0
Do While C < 1000000
C = C + 1
Loop
'MsgBox("il file LOG " & MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_.txt è stato creato con successo, posso continuare? Ti consiglio di apsettare qualche minuto buono", MsgBoxStyle.Information + MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2, "Attendi..")

Do While C < 1000000
C = C + 1
Loop
Exit Do
End If
Else
Dim C As Long = 0
Do While C < 100000
C = C + 1
Loop
End If

System.Windows.Forms.Application.DoEvents()
Loop

System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
' Drive1.Tag = Mid(Drive1.Drive, 1, 1)




I = MsgBox("Attendere prima la chiusura del processo di creazione Log. Procedo a creare il file pulito contenente solo le directory", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "OK")

If I = vbYes Then
GeneraToolStripMenuItem_Click(Nothing, Nothing)
End If



End Sub




Private Sub GeneraToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GeneraToolStripMenuItem.Click

Dim NomeFile As String

If CheckBox5.Checked = True Then
If CheckBox4.Checked = True Then
NomeFile = MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_Portatile_HarDisk_Pulito.txt"
Else
NomeFile = MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_Desktop_HarDisk_Pulito.txt"
End If
ElseIf CheckBox2.Checked = True Then
NomeFile = MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_Desktop_Pulito.txt"
ElseIf CheckBox4.Checked = True Then
NomeFile = MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_Portatile_Pulito.txt"
End If



FileClose(1)
FileClose(2)

Dim LeggiDir As String
If CheckBox2.Checked = True Then
LeggiDir = MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_Desktop.txt"
ElseIf CheckBox4.Checked = True Then
LeggiDir = MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_Portatile.txt"
ElseIf CheckBox5.Checked = True Then
LeggiDir = MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_HarDisk.txt"
End If


FileOpen(1, LeggiDir, OpenMode.Input) 'MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_.txt", OpenMode.Input)



FileOpen(2, NomeFile, OpenMode.Output)
'FileOpen(2, MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_Pulito.txt", OpenMode.Output)


' Panel1.Visible = True

ProgressBar1.Maximum = FileLen(LeggiDir) ' MyDirPath & "\INI\LeggiDir_" & Mid(Drive1.Drive, 1, 1) & "_.txt")
ProgressBar1.Value = 0
Me.Text = "creazione Log in corso ...."
Do While Not EOF(1)
stringa = Trim(LineInput(1))

If (ProgressBar1.Value + Len(stringa)) < ProgressBar1.Maximum Then
ProgressBar1.Value = ProgressBar1.Value + Len(stringa)
Else
ProgressBar1.Value = 0
End If
If Mid(stringa, 1, 13) = "Directory di " Then

' codifica accenti e accentati


stringa = Replace(stringa, "•", "ò")
stringa = Replace(stringa, "‡", "ç")
stringa = Replace(stringa, "…", "à")
stringa = Replace(stringa, "—", "ù")
stringa = Replace(stringa, "õ", "§")
stringa = Replace(stringa, "Š", "è")
stringa = Replace(stringa, "‚", "é")
stringa = Replace(stringa, Chr(141), "ì")
stringa = Replace(stringa, "ï", "'")
stringa = Replace(stringa, "'", Chr(235)) ' apostrofo

PrintLine(2, Mid(stringa, 14, Len(stringa)))

System.Windows.Forms.Application.DoEvents()
End If

Loop
Me.Text = ""
Totale = ProgressBar1.Value
ProgressBar1.Value = 0
FileClose(1)
FileClose(2)
Drive1_SelectedIndexChanged(Nothing, Nothing)
MsgBox("FIle creato con successo", MsgBoxStyle.Information, "OK")
End Sub










( elencodirectoryultimofunzionante.html )- by Paolo Puglisi - Modifica del 17/12/2023