以下、各フォルダのサブディレクトリを取得するコードを記述しました。次に、これらのディレクトリをループして、フォルダの名前だけを取得します。各フォルダーから不足しているサブディレクトリーを見つけ、2つのリストに収集します。
私はここにあるよりも簡単な方法があると思われますが、それは機能します。
'Declare lists for each folders
Dim folder1SubDirectories As New List(Of String)
Dim folder1SubNames As New List(Of String)
Dim folder2SubDirectories As New List(Of String)
Dim folder2SubNames As New List(Of String)
'Declare folders locations as variables
Dim folder1Location As String = "Folder1 path location"
Dim folder2Location As String = "Folder2 path location"
'add the subdirectories of each folder into the appropriate list
folder1SubDirectories.AddRange(Directory.GetDirectories(folder1Location))
'add the name of the subdirectory to a new list
For Each subfolder In folder1SubDirectories
Dim dirInfo As New System.IO.DirectoryInfo(subfolder)
folder1SubNames.Add(dirInfo.Name)
Next
'add the subdirectories of each folder into the appropriate list
folder2SubDirectories.AddRange(Directory.GetDirectories(folder2Location))
'add the names of the subddirectories into a new list
For Each subfolder In folder2SubDirectories
Dim dirInfo As New System.IO.DirectoryInfo(subfolder)
folder2SubNames.Add(dirInfo.Name)
Next
'The below LINQ finds the missing subdirectories and puts them in them in the list
Dim missingSubs = folder1SubNames.Union(folder2SubNames).Except(folder1SubNames.Intersect(folder2SubNames)).ToList()
'Now you can do whatever you need to do with the missing subdirectories
For Each missingSub In missingSubs
Console.WriteLine(missingSub)
Next
Console.ReadLine()
Directory.GetDirectories:https://msdn.microsoft.com/en-us/library/c1sez4sc(v=vs.110).aspxを参照してください。不足しているディレクトリを比較して抽出し、StreamWriterを使用してファイルに出力できます。https://msdn.microsoft.com/en-us/library/system.io.streamwriter(v=vs.110).aspx –
例両方のリンクであなたが必要なものを達成するのに役立ちます –
何か試しましたか?私たちはあなたのための完全なコーディングをしません。 [DirectoryInfo](https://msdn.microsoft.com/en-us/library/system.io.directoryinfo(v = vs.110).aspx)クラスと[Directory.GetDirectories()](https: //msdn.microsoft.com/en-us/library/ms143325(v=vs.110).aspx)メソッドについては、[LINQ](https://msdn.microsoft.com/de-de/library/bb763068)を参照してください。 .aspx)、特に[Intersection](https://msdn.microsoft.com/en-us/library/bb460136(v=vs.110).aspx)を参照してください。 –