Directory e FILES e Driver Nuovo - Solo Form codice




Imports System

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error GoTo Errore
If TextBox1.Text = "" Then
Exit Sub
End If
ListBox1.Items.Clear()

If CheckBox1.Checked = False Then
For Each foundFile As String In My.Computer.FileSystem.GetFiles(TextBox1.Text, SearchOption.SearchTopLevelOnly, "*.*")
foundFile = Replace(foundFile, TextBox1.Text & "\", "")
ListBox1.Items.Add(foundFile)
Next
Else
For Each foundFile As String In My.Computer.FileSystem.GetFiles(TextBox1.Text, SearchOption.SearchAllSubDirectories, "*.*")
ListBox1.Items.Add(foundFile)
Next
End If


Errore:
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim RicordaPath As String
Dim folder As New FolderBrowserDialog
Dim DirStringa As String
If Dir("mypath.ini") <> "" Then
FileOpen(1, "mypath.ini", OpenMode.Input)
RicordaPath = LineInput(1)
FileClose(1)
TextBox1.Text = RicordaPath
Else
RicordaPath = ""
TextBox1.Text = RicordaPath
End If
folder.Description = RicordaPath
folder.SelectedPath = RicordaPath
If folder.ShowDialog = Windows.Forms.DialogResult.OK Then
DirStringa = folder.SelectedPath
TextBox1.Text = DirStringa
FileOpen(1, "mypath.ini", OpenMode.Output)
PrintLine(1, folder.SelectedPath)
FileClose(1)
Else
DirStringa = ""
TextBox1.Text = DirStringa
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim RicordaPath As String
Dim folder As New FolderBrowserDialog
Dim DirStringa As String
If Dir("myDir.ini") <> "" Then
FileOpen(1, "myDir.ini", OpenMode.Input)
RicordaPath = LineInput(1)
FileClose(1)
TextBox2.Text = RicordaPath
Else
RicordaPath = ""
TextBox2.Text = RicordaPath
End If
folder.Description = RicordaPath
folder.SelectedPath = RicordaPath
If folder.ShowDialog = Windows.Forms.DialogResult.OK Then
DirStringa = folder.SelectedPath
TextBox2.Text = DirStringa
FileOpen(1, "myDir.ini", OpenMode.Output)
PrintLine(1, folder.SelectedPath)
FileClose(1)
Else
DirStringa = ""
TextBox2.Text = DirStringa
End If




If TextBox2.Text = "" Then
Exit Sub
End If
ListBox2.Items.Clear()

If CheckBox2.Checked = False Then
For Each foundFile As String In My.Computer.FileSystem.GetDirectories(TextBox2.Text, SearchOption.SearchTopLevelOnly, "*.*")
' foundFile = Replace(foundFile, TextBox2.Text & "\", "")

ListBox2.Items.Add(foundFile)
Next
Else
For Each foundFile As String In My.Computer.FileSystem.GetDirectories(TextBox2.Text, SearchOption.SearchAllSubDirectories, "*.*")
ListBox2.Items.Add(foundFile)
Next
End If

End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
On Error GoTo ERRORE

If Dir("myDrive.ini") <> "" Then
FileOpen(1, "myDrive.ini", OpenMode.Input)
Stringa = LineInput(1)
FileClose(1)
ComboBox1.Text = Stringa

End If

ComboBox1.Items.Clear()
For I = Asc("A") To Asc("Z")
If Dir(Chr(I) & ":\", FileAttribute.Directory) <> "" Then
ComboBox1.Items.Add(Chr(I) & ":\")
End If
Next
ComboBox1.Text = Stringa

ERRORE:
End Sub



Private Sub ComboBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.TextChanged
FileOpen(1, "myDrive.ini", OpenMode.Output)
PrintLine(1, ComboBox1.Text)
FileClose(1)

End Sub



End Class










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