问题描述
我需要在C:\\ Ram目录中创建3个文件夹(名为In,Proc,Error)。首先,我需要检查目录中是否存在文件夹。如果其中任何一个不存在,则需要创建丢失的文件夹。如果所有遗漏都需要创建所有3。有人可以为此要求在VB.NET中建议一个简单的循环代码。
解决方法
Dim folders = New () { \"In\",\"Proc\",\"Error\" }
For Each folder As String In folders
Dim dir = Path.Combine(\"c:\\ram\",folder)
If Not Directory.Exists(dir) Then
Directory.CreateDirectory(dir)
End If
Next