Я пытаюсь заполнить список именами и значениями свойств, вот мой код...
public class DirPropeties {
public string Name { get; set; }
public string Path { get; set; }
public string HiddenStatus { get; set; }
}
public static List<string> GetDirAttributes(string path, bool IsHidden = true)
{
List<DirPropeties> FolderArrayList = new List<DirPropeties>();
DirectoryInfo di = new DirectoryInfo(path);
DirectoryInfo[] subdirectories = di.GetDirectories();
foreach (DirectoryInfo dir in subdirectories)
{
if (IsHidden)
{
//FolderArrayList.Add(dir.Name);
FolderArrayList.Add(new DirPropeties { Name = dir.Name });
}
else if ((dir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
{
FolderArrayList.Add(new DirPropeties { Name = dir.Name });
}
};
return FolderArrayList;
}
Я так это называю....
List<string> DirectoryArrayList = new List<string>();
DirectoryArrayList = BaseDirectory.GetDirAttributes(FileDetailsViewModel.FolderPath, FileDetailsViewModel.AllowHidden);
и я пытаюсь получить доступ к таким свойствам...
if (folderIndex >= DirectoryArrayList.Count) { break; }
var folder = DirectoryArrayList[folderIndex];
var label = new Label()
{
Text = folder.Name,
FontSize = 20,
VerticalTextAlignment = TextAlignment.Center,
HorizontalTextAlignment = TextAlignment.Center
};
Я получаю следующую ошибку при возврате FolderArrayList...
Невозможно неявно преобразовать тип "System.Collections.Generic.List" в "System.Collections.Generic.List"
и в папке. Имя я получаю следующую ошибку...
строка не содержит определения имени
Может ли кто-нибудь помочь мне понять, что мне нужно сделать, чтобы решить эту проблему, пожалуйста?
GetDirAttributes()
должен вернутьList<DirPropeties>
, а неList<string>
, иDirectoryArrayList
имеет ту же проблему. Также должно бытьList<DirPropeties>
. - person Zer0   schedule 07.03.2020