复制到新文件夹后删除所有文件

问题描述 投票:0回答:1

'Start Button'执行以下操作:

  1. 检查.blf文件的给定文件夹路径
  2. 将所有现有的.blf文件复制到目标文件夹
  3. 在文本文件i中显示文件夹的目录,例如。正在创建文件的位置
  4. 显示正在复制现有文件的目录,例如:在服务器上
  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
delete-file file-copying
1个回答
0
投票

我做到了,得到了结果。这更像是一个愚蠢的错误。

  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
© www.soinside.com 2019 - 2024. All rights reserved.