How to Copy a File using VB.Net

0
36

This Tutorial is all about How to Copy a File using VB.Net. In this tutorial you will learn about How to Copy a File using VB.Net. So lets get Started:

  • First is open the Visual Basic, Select File on the menu, then click New and create a new project.

  • Then a New Project Dialog will appear. You can rename your project, depending on what you like to name it. After that click OK

  • Design your form like this just like what I’ve shown you below.
    Add a Textbox, Button and Label.
  • After that add this code to the Source Browse button.
    1. Dim fDialog As New OpenFileDialog
    2. fDialog.ShowDialog()
    3. txtsource.Text = fDialog.FileName
    4. tempFileName = fDialog.SafeFileName
  • Add this code to the Destination Browse button.
    1. Dim fDialog As New FolderBrowserDialog
    2. fDialog.ShowDialog()
    3. txtdestination.Text = fDialog.SelectedPath & "\" & tempFileName
  • Then add this code to the Copy Button.
    1. If txtsource.Text.Length > 0 And txtdestination.Text.Length > 0 Then
    2. My.Computer.FileSystem.CopyFile(txtsource.Text, txtdestination.Text)
    3. MsgBox("Successfully Copied")
    4. End If
  • Finally Click F5 to run.

Output:

 

If you have any comments or suggestion about on How to Copy a File using VB.Net, Please Feel Free to contact our webpage.

Download How to Copy a File using VB.Net Code Here

Other articles you might read also:

Facebook Comments
(Visited 39 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here