/// <summary> /// Necessary for files to be copied /// </summary> /// <param name="sourceDirectoryPath"> /// In the form: 'SCSIDRV' or 'SCSIDRV\AMDAHCI' /// </param> public void AddOptionalSourceDirectory(string sourceDirectoryPath) { if (!SectionNames.Contains("OptionalSrcDirs")) { AddSection("OptionalSrcDirs"); } if (GetLineIndex("OptionalSrcDirs", sourceDirectoryPath) == -1) { AppendLineToSection("OptionalSrcDirs", sourceDirectoryPath); } }
public static void ChangeSectionName(string currentSectionName, string newSectionName) { if (currentSectionName == newSectionName) { return; } if (SectionNames.Contains(newSectionName)) { MergeSections(currentSectionName, newSectionName); } else { RenameSection(currentSectionName, newSectionName); } }
/// <summary> /// The section will be created if it does not exist /// </summary> public void AddFileToFilesSection(string sectionName, string fileName, int winntDirectoryID) { if (!SectionNames.Contains(sectionName)) { AddSection(sectionName); } // Note: the key here is a combination of filename and directory, // so the same file could be copied to two directories. string entry = String.Format("{0},{1}", fileName, winntDirectoryID); int lineIndex = GetLineIndexByKey(sectionName, entry); if (lineIndex == -1) { AppendLineToSection(sectionName, entry); } }
public string GetSectionText(string sectionName) { LoadSections(); if (!SectionNames.Contains(sectionName)) { throw new Exception("No section called '" + sectionName + "'"); } if (string.IsNullOrWhiteSpace(sectionText[sectionName])) { return(""); } XDocument xdoc = XDocument.Parse(sectionText[sectionName]); if (xdoc.Declaration == null) { return(xdoc.ToString()); } else { return(xdoc.Declaration.ToString() + "\r\n" + xdoc.ToString()); } }
public bool SetSectionText(string sectionName, string text) { LoadSections(); if (!SectionNames.Contains(sectionName)) { throw new Exception("No section called '" + sectionName + "'"); } if (text != sectionText[sectionName]) { IsChanged = true; } sectionText[sectionName] = text; bytesInSync = false; if (string.IsNullOrWhiteSpace(text)) { deleteSection(sectionName); } else { setSectionBytes(sectionName); } return(true); }