所以我有一个目录,我想获得所有文件,包括子目录,它们相对于父目录的路径。例子:
Parent directory: "C:test"
File1 located in: "C:testfoobar.txt"
我要检索的是:
"foobar.txt"
我知道怎么用
For Each foundFile As String In My.Computer.FileSystem.GetFiles(Path)
但是它会返回完整的路径给我。
所以你有:
Dim root = "c:temp"
Dim files = My.Computer.FileSystem.GetFiles(root, FileIO.SearchOption.SearchAllSubDirectories)
现在取从根目录长度开始的子字符串
Dim filesWithoutRoot = files.Select(Function(f) f.Substring(root.Length)).ToList