Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
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
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents FolderBrowserDialog1 As System.Windows.Forms.FolderBrowserDialog
Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog
Me.GroupBox1 = New System.Windows.Forms.GroupBox
Me.RadioButton2 = New System.Windows.Forms.RadioButton
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(8, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(128, 26)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = "C:\Nuova Cartella"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(8, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(128, 24)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Directory Or File:"
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button1.Location = New System.Drawing.Point(8, 80)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(128, 24)
Me.Button1.TabIndex = 4
Me.Button1.Text = "Apply"
'
'Button2
'
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Button2.Location = New System.Drawing.Point(144, 80)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(128, 24)
Me.Button2.TabIndex = 5
Me.Button2.Text = "Browse..."
'
'FolderBrowserDialog1
'
Me.FolderBrowserDialog1.Description = "Browse..."
'
'GroupBox1
'
Me.GroupBox1.Controls.Add(Me.RadioButton2)
Me.GroupBox1.Controls.Add(Me.RadioButton1)
Me.GroupBox1.Location = New System.Drawing.Point(144, 0)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(192, 72)
Me.GroupBox1.TabIndex = 6
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Scegli Un Opzione:"
'
'RadioButton2
'
Me.RadioButton2.Location = New System.Drawing.Point(8, 48)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.Size = New System.Drawing.Size(168, 16)
Me.RadioButton2.TabIndex = 1
Me.RadioButton2.Text = "Cancella Una Cartella:"
'
'RadioButton1
'
Me.RadioButton1.Location = New System.Drawing.Point(8, 24)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.Size = New System.Drawing.Size(168, 16)
Me.RadioButton1.TabIndex = 0
Me.RadioButton1.Text = "Cancella Un File:"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
Me.ClientSize = New System.Drawing.Size(338, 112)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Font = New System.Drawing.Font("Comic Sans MS", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.Name = "Form1"
Me.Opacity = 0.85
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Delete Directory Or File by Citynova"
Me.GroupBox1.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
OpenFileDialog1.Filter = "Tutti i file (*.*)|*.*"
If RadioButton1.Checked = True Then
OpenFileDialog1.ShowDialog()
TextBox1.Text = OpenFileDialog1.FileName
Else
FolderBrowserDialog1.ShowDialog()
TextBox1.Text = FolderBrowserDialog1.SelectedPath
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Select Case RadioButton1.CausesValidation And RadioButton2.CausesValidation
Case RadioButton1.Checked = False And RadioButton2.Checked = False
MsgBox("Scegli Un Opzione!", MsgBoxStyle.Exclamation, "Error")
Case RadioButton1.Checked = True And RadioButton2.Checked = False
Kill(TextBox1.Text)
Case RadioButton1.Checked = False And RadioButton2.Checked = True
DelTree(TextBox1.Text)
End Select
End Sub
Private Sub DelTree(ByVal SFolder As String)
Dim sCurrFile As String
sCurrFile = Dir(SFolder & "\*.*", vbDirectory)
Do While Len(sCurrFile) > 0
If sCurrFile <> "." And sCurrFile <> ".." Then
If (GetAttr(SFolder & "\" & sCurrFile) And vbDirectory) = _
vbDirectory Then
Call DelTree(SFolder & "\" & sCurrFile)
sCurrFile = Dir(SFolder & "\*.*", vbDirectory)
Else
Kill(SFolder & "\" & sCurrFile)
sCurrFile = Dir()
End If
Else
sCurrFile = Dir()
End If
Loop
RmDir(SFolder)
End Sub
End Class