Option Explicit On
Option Strict On
Friend Class frmMain
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.
Private WithEvents txtSource As System.Windows.Forms.TextBox
Private WithEvents btnSource As System.Windows.Forms.Button
Private WithEvents btnPerform As System.Windows.Forms.Button
Private WithEvents radMove As System.Windows.Forms.RadioButton
Private WithEvents radCopy As System.Windows.Forms.RadioButton
Private WithEvents lblSource As System.Windows.Forms.Label
Private WithEvents lblDestination As System.Windows.Forms.Label
Private WithEvents btnExit As System.Windows.Forms.Button
Private WithEvents ofdSource As System.Windows.Forms.OpenFileDialog
Private WithEvents sfdDestination As System.Windows.Forms.SaveFileDialog
Private WithEvents txtDestination As System.Windows.Forms.TextBox
Private WithEvents btnDestination As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.txtSource = New System.Windows.Forms.TextBox
Me.txtDestination = New System.Windows.Forms.TextBox
Me.btnSource = New System.Windows.Forms.Button
Me.btnDestination = New System.Windows.Forms.Button
Me.btnPerform = New System.Windows.Forms.Button
Me.radMove = New System.Windows.Forms.RadioButton
Me.radCopy = New System.Windows.Forms.RadioButton
Me.lblSource = New System.Windows.Forms.Label
Me.lblDestination = New System.Windows.Forms.Label
Me.btnExit = New System.Windows.Forms.Button
Me.ofdSource = New System.Windows.Forms.OpenFileDialog
Me.sfdDestination = New System.Windows.Forms.SaveFileDialog
Me.SuspendLayout()
'
'txtSource
'
Me.txtSource.Location = New System.Drawing.Point(8, 40)
Me.txtSource.Name = "txtSource"
Me.txtSource.Size = New System.Drawing.Size(376, 20)
Me.txtSource.TabIndex = 0
Me.txtSource.Text = ""
'
'txtDestination
'
Me.txtDestination.Location = New System.Drawing.Point(8, 112)
Me.txtDestination.Name = "txtDestination"
Me.txtDestination.Size = New System.Drawing.Size(376, 20)
Me.txtDestination.TabIndex = 1
Me.txtDestination.Text = ""
'
'btnSource
'
Me.btnSource.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnSource.Location = New System.Drawing.Point(392, 40)
Me.btnSource.Name = "btnSource"
Me.btnSource.Size = New System.Drawing.Size(24, 20)
Me.btnSource.TabIndex = 2
Me.btnSource.Text = "..."
'
'btnDestination
'
Me.btnDestination.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnDestination.Location = New System.Drawing.Point(392, 112)
Me.btnDestination.Name = "btnDestination"
Me.btnDestination.Size = New System.Drawing.Size(24, 20)
Me.btnDestination.TabIndex = 3
Me.btnDestination.Text = "..."
'
'btnPerform
'
Me.btnPerform.Location = New System.Drawing.Point(24, 192)
Me.btnPerform.Name = "btnPerform"
Me.btnPerform.TabIndex = 4
Me.btnPerform.Text = "&Perform"
'
'radMove
'
Me.radMove.Location = New System.Drawing.Point(136, 160)
Me.radMove.Name = "radMove"
Me.radMove.TabIndex = 5
Me.radMove.Text = "&Move"
'
'radCopy
'
Me.radCopy.Checked = True
Me.radCopy.Location = New System.Drawing.Point(16, 160)
Me.radCopy.Name = "radCopy"
Me.radCopy.TabIndex = 6
Me.radCopy.TabStop = True
Me.radCopy.Text = "&Copy"
'
'lblSource
'
Me.lblSource.Location = New System.Drawing.Point(8, 16)
Me.lblSource.Name = "lblSource"
Me.lblSource.TabIndex = 7
Me.lblSource.Text = "Source File:"
Me.lblSource.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'lblDestination
'
Me.lblDestination.Location = New System.Drawing.Point(8, 88)
Me.lblDestination.Name = "lblDestination"
Me.lblDestination.TabIndex = 8
Me.lblDestination.Text = "Destination:"
Me.lblDestination.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(344, 192)
Me.btnExit.Name = "btnExit"
Me.btnExit.TabIndex = 9
Me.btnExit.Text = "E&xit"
'
'ofdSource
'
Me.ofdSource.Title = "Select A File"
'
'sfdDestination
'
Me.sfdDestination.Title = "Select A Destination"
'
'frmMain
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(424, 223)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.lblDestination)
Me.Controls.Add(Me.lblSource)
Me.Controls.Add(Me.radCopy)
Me.Controls.Add(Me.radMove)
Me.Controls.Add(Me.btnPerform)
Me.Controls.Add(Me.btnDestination)
Me.Controls.Add(Me.btnSource)
Me.Controls.Add(Me.txtDestination)
Me.Controls.Add(Me.txtSource)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.Name = "frmMain"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ofdSource.FileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\*.*"
sfdDestination.FileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\*.*"
End Sub
Private Sub btnSource_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSource.Click
Dim dlgResult As DialogResult = ofdSource.ShowDialog()
If dlgResult <> DialogResult.Cancel Then txtSource.Text = ofdSource.FileName
End Sub
Private Sub btnDestination_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDestination.Click
Dim dlgResult As DialogResult = sfdDestination.ShowDialog
If dlgResult <> DialogResult.Cancel Then txtDestination.Text = sfdDestination.FileName
End Sub
Private Sub btnPerform_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPerform.Click
If System.IO.File.Exists(txtSource.Text) = True Then
Try
If radCopy.Checked = True Then
System.IO.File.Copy(txtSource.Text, txtDestination.Text, True)
Else
System.IO.File.Move(txtSource.Text, txtDestination.Text)
End If
Catch ex As Exception
MessageBox.Show("Can't copy or move!" & ControlChars.NewLine & ex.Message, "Can't copy or move...", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class