<mat-dialog-content>
<form [formGroup]="carForm" novalidate>
<mat-form-field class="example-chip-list">
<mat-chip-list #chipList>
<mat-chip *ngFor="let car of cars" [selectable]="selectable"
[removable]="removable" (removed)="remove(car)">
{{car.name}}
<mat-icon matChipRemove *ngIf="removable">cancel</mat-icon>
</mat-chip>
<input matInput
formControlName="cars"
placeholder="New car..."
[matChipInputFor]="chipList"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes"
[matChipInputAddOnBlur]="addOnBlur"
(matChipInputTokenEnd)="add($event)"
required>
</mat-chip-list>
</mat-form-field>
</form>
</mat-dialog-content>
<mat-dialog-actions>
<button mat-raised-button [mat-dialog-close]="carForm.value" tabindex="1" [disabled]="!carForm.valid" color="primary">Save</button>
<button mat-button [mat-dialog-close]="null" tabindex="-1">Cancel</button>
</mat-dialog-actions>
是路径,即directory
,可能包含也可能不包含名为L:\\H435431 Project Name
或2-Storage
的子目录。如果发现了该目录,我想获取其子目录的列表并进行测试以查看其是否包含2-STORAGE
。
当我逐步执行此代码时,! Issued Packages
返回期望的文件夹数组,并且subdirectories
已正确设置为containsStorage
。反过来,true
可以正确反映我接下来要搜索的目录名称d
。 L:\\H435431 Project Name\\2-Storage
永远不会被分配ad
的值,并且永远不会搜索目录。为什么会这样?
Directory.GetDirectories(d)
答案 0 :(得分:1)
检查SubSubDirectories对我们是否为空,如果其中没有内容,则没有任何内容可以迭代。
string[] subirectories = Directory.GetDirectories(directory);
foreach (string d in subirectories)
{
if (Regex.IsMatch(d, @"2-Storage", RegexOptions.IgnoreCase))
{
containsStorage = true;
string[] subSubDirectories = Directory.GetDirectories(d);
foreach (string ad in subSubDirectories)
{
if (Regex.IsMatch(ad, @"! Issued Packages", RegexOptions.IgnoreCase))
{
containsIssued = true;
}
}
}
}