private void AddSection(string file, string section) { var infPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "INF", file); Files.Add(infPath); try { var reader = new INFReader(infPath); // Check for catalog file var version = reader.GetSection("Version"); if (version.ContainsKey("CatalogFile")) { foreach (var catalog in version["CatalogFile"]) { Files.Add(catalog); } } var data = reader.GetSection(section); if (data.Keys.Count == 0) throw new Exception("No data in section"); // Reference another INF if (data.ContainsKey("Include") && data.ContainsKey("Needs")) { for (var index = 0; index < data["Include"].Count; index++) { var refName = data["Include"][index]; var refSection = data["Needs"][index]; AddSection(refName, refSection); } } // CopyFiles if (data.ContainsKey("CopyFiles")) { foreach (var fileData in data["CopyFiles"]) { if (fileData.Contains("@")) AddFile(Files, fileData); else AddFiles(Files, reader, fileData); } } } catch (Exception ex) { //MessageBox.Show("ERR: " + ex.Message); } }
private void AddFiles(List<string> files, INFReader reader, string data) { data = data.Trim(); var section = reader.GetSection(data); files.AddRange(section[""]); }