public dlcModel[] GetDLCs() { var path = Path.Combine(Directory.GetCurrentDirectory(), "dlc"); List <dlcModel> dlcs = new List <dlcModel>(); foreach (var dir in Directory.GetDirectories(path)) { try { DirectoryInfo dInfo = new DirectoryInfo(dir); var dlcFullPath = dInfo.GetFilesByExtensions(".dlc").First().FullName; var dlc = new dlcModel(); var x = File.ReadLines(dlcFullPath); dlc.name = x.First().Split('"')[1].Replace('"', ' '); dlc.path = x.ElementAt(1).Split('"')[1].Replace('"', ' ').Split('.').First() + ".dlc"; var party = x.ElementAt(x.Count() - 2).Split('=')[1].Replace(" ", ""); if (party == "yes") { dlc._3rdparty = true; userControl11._3rdParty = true; } else { dlc._3rdparty = false; } dlcs.Add(dlc); } catch (Exception ex) { } } return(dlcs.ToArray()); }
public dlcModel[] GetDLCs() { string path = Path.Combine(Directory.GetCurrentDirectory(), "dlc"); List <dlcModel> dlcs = new List <dlcModel>(); foreach (string dir in Directory.GetDirectories(path)) { try { DirectoryInfo dInfo = new DirectoryInfo(dir); string dlcFullPath = dInfo.GetFilesByExtensions(".dlc").First().FullName; dlcModel dlc = new dlcModel(); IEnumerable <string> x = File.ReadLines(dlcFullPath); dlc.name = x.First().Split('"')[1].Replace('"', ' '); dlc.path = x.ElementAt(1).Split('"')[1].Replace('"', ' ').Split('.').First() + ".dlc"; string party = x.ElementAt(x.Count() - 2).Split('=')[1].Replace(" ", ""); if (party == "yes") { dlc._3rdparty = true; button2.BackgroundImage = Properties.Resources.play3rd; } else { dlc._3rdparty = false; button2.BackgroundImage = Properties.Resources.play; } dlcs.Add(dlc); } catch (Exception) { } } return(dlcs.ToArray()); }