Imports System.IO
Public Class Form3
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
TextBox1.Text = Path.GetFileName(OpenFileDialog1.FileName)
TextBox2.Text = Path.GetDirectoryName(OpenFileDialog1.FileName) & "\" & Path.GetFileName(OpenFileDialog1.FileName)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
FolderBrowserDialog1.ShowDialog()
TextBox3.Text = FolderBrowserDialog1.SelectedPath.ToString
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If System.IO.File.Exists(TextBox3.Text & "\" & TextBox1.Text) Then
'MsgBox("the file exists")
File.AppendAllText(TextBox2.Text, TextBox3.Text & "\" & TextBox1.Text)
Else
File.Copy(TextBox2.Text, TextBox3.Text & "\" & TextBox1.Text)
MsgBox("file copied successfully")
End If
End Sub
End Class
No comments:
Post a Comment