Удалить все файлы после копирования в новую папку - PullRequest
0 голосов
/ 03 сентября 2018

'Start Button' выполняет следующие действия:

  1. Проверьте указанный путь к папке для .blf файлов
  2. Скопируйте все существующие .blf файлы в папку назначения
  3. Показать каталог папки в текстовом файле i, e. где файлы создаются
  4. Показать каталог, в который копируются существующие файлы i, e. На сервер
  5. Удалить файл из родительской папки после копирования

Как я могу выполнить пункт 5. Где я виноват?

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

1 Ответ

0 голосов
/ 04 сентября 2018

Я сделал это и получил результат. Это было больше похоже на глупую ошибку.

  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
...