我正在尝试将C:\中的所有pdf文件移动到H:\
I googled and was not able to find a sufficient answer. Only if you know the exact file name.
答案 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