How to convert DriveInfo[] to List<string> C# -
hi want convert driveinfo type list string type list using loop.in code trying use tolist() it's not exist. want paths of logical drives in string list without using loop. know manually it's possible use loop want direct function. thank.
here's code
driveinfo[] drive_info = driveinfo.getdrives(); list<string> list = drive_info.tolist<string>();
try code:
driveinfo[] drive_info = driveinfo.getdrives(); list<string> list = drive_info.select(x => x.rootdirectory.fullname).tolist();
if i'm not wrong takes path drives. using select can make new ienumerable property choose. using tolist() convert list.
Comments
Post a Comment