Imports System
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Dim percorso As String
#Region " Codice generato da Progettazione Windows Form "
Public Sub New()
MyBase.New()
'Chiamata richiesta da Progettazione Windows Form.
InitializeComponent()
'Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent()
End Sub
'Form esegue l'override del metodo Dispose per pulire l'elenco dei componenti.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Richiesto da Progettazione Windows Form
Private components As System.ComponentModel.IContainer
'NOTA: la procedura che segue è richiesta da Progettazione Windows Form.
'Può essere modificata in Progettazione Windows Form.
'Non modificarla nell'editor del codice.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents FolderBrowserDialog1 As System.Windows.Forms.FolderBrowserDialog
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Button1 = New System.Windows.Forms.Button
Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog
Me.ListBox1 = New System.Windows.Forms.ListBox
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Button2 = New System.Windows.Forms.Button
Me.Button3 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.Button1.Location = New System.Drawing.Point(8, 248)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 0
Me.Button1.Text = "Sfoglia"
'
'FolderBrowserDialog1
'
Me.FolderBrowserDialog1.Description = "Cerca Cartella"
Me.FolderBrowserDialog1.RootFolder = System.Environment.SpecialFolder.MyComputer
Me.FolderBrowserDialog1.ShowNewFolderButton = False
'
'ListBox1
'
Me.ListBox1.Location = New System.Drawing.Point(8, 8)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.ScrollAlwaysVisible = True
Me.ListBox1.Size = New System.Drawing.Size(592, 238)
Me.ListBox1.TabIndex = 1
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox1.Location = New System.Drawing.Point(8, 280)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(592, 22)
Me.TextBox1.TabIndex = 2
Me.TextBox1.Text = ""
'
'Button2
'
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.Button2.Location = New System.Drawing.Point(488, 248)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(112, 23)
Me.Button2.TabIndex = 3
Me.Button2.Text = "Rinomina Selezionato"
'
'Button3
'
Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.System
Me.Button3.Location = New System.Drawing.Point(408, 248)
Me.Button3.Name = "Button3"
Me.Button3.TabIndex = 4
Me.Button3.Text = "Aggiorna Lista"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(606, 308)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.ListBox1)
Me.Controls.Add(Me.Button1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Rinomina File By GoLDBeRG"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error Resume Next
FolderBrowserDialog1.ShowDialog()
percorso = Me.FolderBrowserDialog1.SelectedPath
Dim a As Integer
file = Directory.
GetFiles(percorso
)
For a
= 1
To file.
Length - 1
ListBox1.
Items.
Add(file(a
))
Next a
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
On Error GoTo errore
Rename(ListBox1.SelectedItem, TextBox1.Text)
Dim index As Integer = ListBox1.SelectedIndex
ListBox1.Items.Clear()
Dim a As Integer
file = Directory.
GetFiles(percorso
)
For a
= 1
To file.
Length - 1
ListBox1.
Items.
Add(file(a
))
Next a
ListBox1.SelectedIndex = index + 1
Exit Sub
errore: MessageBox.Show("Questo file esiste gia!!Cambiare Nome!", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
TextBox1.Text = ListBox1.SelectedItem
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then Button2.PerformClick()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim index As Integer = ListBox1.SelectedIndex
ListBox1.Items.Clear()
Dim a As Integer
file = Directory.
GetFiles(percorso
)
For a
= 1
To file.
Length - 1
ListBox1.
Items.
Add(file(a
))
Next a
ListBox1.SelectedIndex = index
End Sub
End Class
Public Class Main
Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New Form1)
End Sub
End Class