如何将所有pdf文件移动到另一个目录

时间:2015-03-31 21:18:54

标签: vb.net

我正在尝试将C:\中的所有pdf文件移动到H:\

I googled and was not able to find a sufficient answer. Only if you know the exact file name.

2 个答案:

答案 0 :(得分:1)

For Each x In My.Computer.FileSystem.GetFiles("C:\", FileIO.SearchOption.SearchTopLevelOnly) ' Or SearchAllSubDirectories
        If x.EndsWith(".pdf") Then IO.File.Copy(x, "H:\", False) 'Overwrite = FALSE
    Next

答案 1 :(得分:0)

        For Each x In New DirectoryInfo("C:\").GetFiles("*.pdf", SearchOption.TopDirectoryOnly)' or AllDirectories
            File.Copy(x.FullName, Path.Combine("H:\", x.Name), False) 'Overwrite = FALSE
        Next