A R.
A R.

Reputation: 333

Delete all the files after copying in new folder

'Start Button' does the following:

  1. Check the given folder path for .blf files
  2. Copy all the existing .blf files to the destination folder
  3. Show the directory of the folder in text file i,e. where the files are being created
  4. Show the directory where the existing files are being copied i,e. Onto the server
  5. Delete the file from parent folder after copying

How can i do the Point 5..where am i at fault?

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Const DestinationDirectory As String = "C:\Users\nha4abt\Desktop\Move_Here"
    'Show the parent folder path
    TextBox1.Text = "C:\Users\nha4abt\Desktop\Ahmad_examaning_folder"
    ' Show the destination folder path
    TextBox2.Text = DestinationDirectory
    For Each FileName As String In directory.GetFiles("C:\Users\nha4abt\Desktop\Ahmad_examaning_folder", "*.blf")
        File.Copy(FileName, Path.Combine(DestinationDirectory, Path.GetFileName(FileName)))
        ListBox1.Items.Clear()
        ListBox1.Items.Add(FileName)
    Next FileName

    For Each FileName In As String In directory.GetFiles("C:\Users\nha4abt\Desktop\Ahmad_examaning_folder", "*.blf")
        File.Delete(Path.GetFileName(FileName))
    Next FileName
End Sub

Upvotes: 0

Views: 53

Answers (1)

A R.
A R.

Reputation: 333

I did that and got the result. It was more like a silly mistake.

  Const DestinationDirectory As String = "C:\Users\nha4abt\Desktop\Move_Here"
    'Show the parent folder path
    Const ParentDirectory As String = "C:\Users\nha4abt\Desktop\Ahmad_examaning_folder"
    TextBox1.Text = ParentDirectory
    ' Show the destination folder path
    TextBox2.Text = DestinationDirectory
    ListBox1.Items.Clear()
    For Each FileName As String In Directory.GetFiles(ParentDirectory, "*.blf")
        File.Copy(FileName, Path.Combine(DestinationDirectory, Path.GetFileName(FileName)))
        File.Delete(FileName)
        ListBox1.Items.Add(FileName)
    Next FileName

End Sub

Upvotes: 1

Related Questions