Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Delector - Form1.vb

Form1.vb

Caricato da:
Scarica il programma completo

  1. Public Class Form1
  2.     Inherits System.Windows.Forms.Form
  3.  
  4. #Region " Windows Form Designer generated code "
  5.  
  6.     Public Sub New()
  7.         MyBase.New()
  8.  
  9.         'This call is required by the Windows Form Designer.
  10.         InitializeComponent()
  11.  
  12.         'Add any initialization after the InitializeComponent() call
  13.  
  14.     End Sub
  15.  
  16.     'Form overrides dispose to clean up the component list.
  17.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  18.         If disposing Then
  19.             If Not (components Is Nothing) Then
  20.                 components.Dispose()
  21.             End If
  22.         End If
  23.         MyBase.Dispose(disposing)
  24.     End Sub
  25.  
  26.     'Required by the Windows Form Designer
  27.     Private components As System.ComponentModel.IContainer
  28.  
  29.     'NOTE: The following procedure is required by the Windows Form Designer
  30.     'It can be modified using the Windows Form Designer.  
  31.     'Do not modify it using the code editor.
  32.     Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
  33.     Friend WithEvents Label1 As System.Windows.Forms.Label
  34.     Friend WithEvents Button1 As System.Windows.Forms.Button
  35.     Friend WithEvents Button2 As System.Windows.Forms.Button
  36.     Friend WithEvents FolderBrowserDialog1 As System.Windows.Forms.FolderBrowserDialog
  37.     Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
  38.     Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
  39.     Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
  40.     Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
  41.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  42.         Me.TextBox1 = New System.Windows.Forms.TextBox
  43.         Me.Label1 = New System.Windows.Forms.Label
  44.         Me.Button1 = New System.Windows.Forms.Button
  45.         Me.Button2 = New System.Windows.Forms.Button
  46.         Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog
  47.         Me.GroupBox1 = New System.Windows.Forms.GroupBox
  48.         Me.RadioButton2 = New System.Windows.Forms.RadioButton
  49.         Me.RadioButton1 = New System.Windows.Forms.RadioButton
  50.         Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
  51.         Me.GroupBox1.SuspendLayout()
  52.         Me.SuspendLayout()
  53.         '
  54.         'TextBox1
  55.         '
  56.         Me.TextBox1.Location = New System.Drawing.Point(8, 24)
  57.         Me.TextBox1.Name = "TextBox1"
  58.         Me.TextBox1.Size = New System.Drawing.Size(128, 26)
  59.         Me.TextBox1.TabIndex = 0
  60.         Me.TextBox1.Text = "C:\Nuova Cartella"
  61.         '
  62.         'Label1
  63.         '
  64.         Me.Label1.Location = New System.Drawing.Point(8, 0)
  65.         Me.Label1.Name = "Label1"
  66.         Me.Label1.Size = New System.Drawing.Size(128, 24)
  67.         Me.Label1.TabIndex = 1
  68.         Me.Label1.Text = "Directory Or File:"
  69.         '
  70.         'Button1
  71.         '
  72.         Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
  73.         Me.Button1.Location = New System.Drawing.Point(8, 80)
  74.         Me.Button1.Name = "Button1"
  75.         Me.Button1.Size = New System.Drawing.Size(128, 24)
  76.         Me.Button1.TabIndex = 4
  77.         Me.Button1.Text = "Apply"
  78.         '
  79.         'Button2
  80.         '
  81.         Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat
  82.         Me.Button2.Location = New System.Drawing.Point(144, 80)
  83.         Me.Button2.Name = "Button2"
  84.         Me.Button2.Size = New System.Drawing.Size(128, 24)
  85.         Me.Button2.TabIndex = 5
  86.         Me.Button2.Text = "Browse..."
  87.         '
  88.         'FolderBrowserDialog1
  89.         '
  90.         Me.FolderBrowserDialog1.Description = "Browse..."
  91.         '
  92.         'GroupBox1
  93.         '
  94.         Me.GroupBox1.Controls.Add(Me.RadioButton2)
  95.         Me.GroupBox1.Controls.Add(Me.RadioButton1)
  96.         Me.GroupBox1.Location = New System.Drawing.Point(144, 0)
  97.         Me.GroupBox1.Name = "GroupBox1"
  98.         Me.GroupBox1.Size = New System.Drawing.Size(192, 72)
  99.         Me.GroupBox1.TabIndex = 6
  100.         Me.GroupBox1.TabStop = False
  101.         Me.GroupBox1.Text = "Scegli Un Opzione:"
  102.         '
  103.         'RadioButton2
  104.         '
  105.         Me.RadioButton2.Location = New System.Drawing.Point(8, 48)
  106.         Me.RadioButton2.Name = "RadioButton2"
  107.         Me.RadioButton2.Size = New System.Drawing.Size(168, 16)
  108.         Me.RadioButton2.TabIndex = 1
  109.         Me.RadioButton2.Text = "Cancella Una Cartella:"
  110.         '
  111.         'RadioButton1
  112.         '
  113.         Me.RadioButton1.Location = New System.Drawing.Point(8, 24)
  114.         Me.RadioButton1.Name = "RadioButton1"
  115.         Me.RadioButton1.Size = New System.Drawing.Size(168, 16)
  116.         Me.RadioButton1.TabIndex = 0
  117.         Me.RadioButton1.Text = "Cancella Un File:"
  118.         '
  119.         'Form1
  120.         '
  121.         Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
  122.         Me.ClientSize = New System.Drawing.Size(338, 112)
  123.         Me.Controls.Add(Me.GroupBox1)
  124.         Me.Controls.Add(Me.Button2)
  125.         Me.Controls.Add(Me.Button1)
  126.         Me.Controls.Add(Me.Label1)
  127.         Me.Controls.Add(Me.TextBox1)
  128.         Me.Font = New System.Drawing.Font("Comic Sans MS", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  129.         Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
  130.         Me.MaximizeBox = False
  131.         Me.Name = "Form1"
  132.         Me.Opacity = 0.85
  133.         Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  134.         Me.Text = "Delete Directory Or File by Citynova"
  135.         Me.GroupBox1.ResumeLayout(False)
  136.         Me.ResumeLayout(False)
  137.  
  138.     End Sub
  139.  
  140. #End Region
  141.  
  142.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  143.         OpenFileDialog1.Filter = "Tutti i file (*.*)|*.*"
  144.         If RadioButton1.Checked = True Then
  145.             OpenFileDialog1.ShowDialog()
  146.             TextBox1.Text = OpenFileDialog1.FileName
  147.         Else
  148.             FolderBrowserDialog1.ShowDialog()
  149.             TextBox1.Text = FolderBrowserDialog1.SelectedPath
  150.         End If
  151.     End Sub
  152.  
  153.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  154.         Select Case RadioButton1.CausesValidation And RadioButton2.CausesValidation
  155.             Case RadioButton1.Checked = False And RadioButton2.Checked = False
  156.                 MsgBox("Scegli Un Opzione!", MsgBoxStyle.Exclamation, "Error")
  157.             Case RadioButton1.Checked = True And RadioButton2.Checked = False
  158.                 Kill(TextBox1.Text)
  159.             Case RadioButton1.Checked = False And RadioButton2.Checked = True
  160.                 DelTree(TextBox1.Text)
  161.         End Select
  162.     End Sub
  163.     Private Sub DelTree(ByVal SFolder As String)
  164.         Dim sCurrFile As String
  165.         sCurrFile = Dir(SFolder & "\*.*", vbDirectory)
  166.         Do While Len(sCurrFile) > 0
  167.             If sCurrFile <> "." And sCurrFile <> ".." Then
  168.                 If (GetAttr(SFolder & "\" & sCurrFile) And vbDirectory) = _
  169.                 vbDirectory Then
  170.                     Call DelTree(SFolder & "\" & sCurrFile)
  171.                     sCurrFile = Dir(SFolder & "\*.*", vbDirectory)
  172.                 Else
  173.                     Kill(SFolder & "\" & sCurrFile)
  174.                     sCurrFile = Dir()
  175.                 End If
  176.             Else
  177.                 sCurrFile = Dir()
  178.             End If
  179.         Loop
  180.         RmDir(SFolder)
  181.     End Sub
  182. End Class